The stupid question is the question not asked | |
PerlMonks |
Re: What does this regex do?by MrYoya (Monk) |
on Apr 01, 2003 at 19:25 UTC ( [id://247322]=note: print w/replies, xml ) | Need Help?? |
/^-?\.?\d+(?:\.\d+)?$/
It means match if there's a - in front or not, followed by an optional . (period), then one or more digits, then optionally a . (period) followed by one or more digits. Since it's anchored at the front and back, that's all it can match. So it matches numbers like -.5 or 5.5522 or -62.0 Since it's using the !~, it'll match anything but that.
In Section
Seekers of Perl Wisdom
|
|