Keep It Simple, Stupid | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
that's easy to fix (untested):
qr/(?:+|-)?\d+(?:\.)?(?:\d+)?(?:[Ee](?:+|-)?\d+)/ piece by piece: I don't think I left anything out. Now, this won't match .4 as a number.... You can build a regex that will handle that case properly as well. But the simple fix of making the part before the decimal optional causes another bug, it maks every part optional, so the null string would be a match, and since every string starts with a null string, every string would match. Since all we have is a number, we could anchor to the begenning and end of the value, but then, the empty string would still match. Thinking back to his origonial question, this should be anchored to the front and back, so more like qr/^...$/. -Ted In reply to Re: Re: Re: Checking whether a $var is a number
by Ted Nitz
|
|