I want to match any number with a regular expression. I have written this expression (added whitespace for readability):
( ([0-9]+(\.[0-9]*)?) | (\.[0-9]+) )( (e|E)(\+|\-)[0-9](\.[0-9])? )?
This would need to match any number in one of the following forms:
1234512.345.1234512345.12e-345or12E-34512e+345or12E+345
It matches the first four notations, but the last four (those with e- and e+) don’t. What have I done wrong? Thanks in advance.
Focus on that part of the expression:
You’re only allowing one digit after
e|E, optionally followed by a.and one other digit.