Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Regular Expression Currency Check

by Tomtom (Scribe)
on Jun 02, 2005 at 13:49 UTC ( [id://462915]=note: print w/replies, xml ) Need Help??


in reply to Regular Expression Currency Check

Try this :
/^\$?(?:\d{1,3},?(?=\d{3}))*[0-9]{1,3}(?:\.\d{2})?$/
I added (?=\d{3}) for a look ahead, otherwise, it matches things like "2,34,3.56". If you have a comma, you're supposed to have three digits just afterwards. ( I hope I'm being clear enough ).
Moreover, you could add "?:" since you're not capturing any pattern.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://462915]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-25 14:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found