I need regular expression to match strings, which begin from number (number can be integer or float). For example:
100px
100 px
1.0ft
1.0 ft
0.001ft2
0.001 ft2
I’m new in this stuff, can anyone help me, please? I’ve already tried something like:
Regex numberBeginRegex = new Regex(@"([\d]+|[\d]+[.][\d]+).");
You can use this regex: –
(\d+(\.\d+)?)– matches integer number or floating point numbers. The fractional part is made optional by using?quantifier, which means –match 0 or 1Actually your regex would have worked too, but you forgot to put
*quantifier at the end of.: –