in reply to Re: Stupid regex question - numerics
in thread Stupid regex question - numerics

Useless use of square brackets detected! Useless use of backslash detected! Exactly zero of the 8 square brackets in your regexp are needed.1 /^([\-]*[\d]+[\.]*[\d]*)$/ is identical to /^(-*\d+\.*\d*)$/. Furthermore, your regexp also matches -----------------------1.................................. It's doubtful the OP wants to match that. I think you want to use ? in all but one of the cases you wrote *.

Also note that your regexp doesn't match .123. But it does match ٦৬६.

1The square brackets don't add anything to the readability. Furthermore, pre-5.10, character classes consisting of a single character are significantly slower than using said character directly (many optimizations won't happen if there's a character class).