I think, this would be equivalent:
/^-?(\d*)\.?(\d*)$/
OTOH: I wouldn't consider "-." a legal number.
So maybe this is better?
/^-?((\d+\.\d*)|(\.?\d+))$/
This wouldn't capture like yours does, but the captured parts aren't used. So you might want to consider using (?:...)...
In reply to Re^2: combined into a single regex
by Skeeve
in thread combined into a single regex
by arcnon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |