-2

I am using python to parse some strings that contain numbers and I want to find a regex that will extract all kind of scenarios:

.2345 0.934 12.3 11.0

Tried something like:

((\-|\+)?[0-9]+(\.[0-9]+)?)

But it seems like cases with .number are not covered.

Andy Lester
  • 91,102
  • 13
  • 100
  • 152
Sogard N
  • 101
  • 1
  • 9

1 Answers1

-1

Your RegEx is correct, but you want to parse numbers which starts with . also, so you can add \. along with \-|\+ as follow: ((\-|\+)?(\.)?[0-9]+(\.[0-9]+)?)

Note: It will match .1.1

Hardik
  • 139
  • 1
  • 10