[\+\-]?\d+(\.\d*)?
This will match any signed float, if you don't want signs or are parsing an equation remove [\+\-]?
so you have \d+(\.\d+)?
Explanation:
\d+
matches any integer()?
means the contents of the parentheses are optional but always have to appear togetherSo this expression will match
5
+5
-5
5.5
+5.5
-5.5