I'm using http://gskinner.com/RegExr/ to test my regex: [+-]?\d+\.?\d*(e[+-]?\d+)?. It's supposed to match floating point numbers. Currently it doesn't match .x, but I want to make it do that.
I tried changing it to [+-]?\d*\.?\d*(e[+-]?\d+)? (changed + to *) but that's an error. What's going wrong here?
Update: is it because everything is optional?
Change the \.? to \. and it will work:
[+-]?\d*\.\d*(e[+-]?\d+)?
I suppose that the point is not optional.
But if you want to make it so, then describe it better with [.]+.
As @h2ooooooo mentioned it seems to be a bug in the as3 implementation of regex.
\d+\.?\d+ // works
\d*\.?\d+ // works
\d*\.?\d* // does not work
\d?\.?\d? // does not work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With