what the regular expression of a line of string containing ONLY float numbers separated with spaces or tabs. The float number can be negative, like -999.999
what the regular expression of a line of string containing ONLY float numbers separated
Share
Let’s come up with a regex for a float, and then see what we can do about the rest.
A float is:
Put that together, and we get:
Now, this is pretty loose, but you can tweak it if you want to tighten it up a little. Now, for any number of these with spaces in between, it’s pretty trivial:
Put it all together, we end up with: