Solved

# Requirement for regex for currency amounts

Posted on 2009-05-13
289 Views
Hi there, I need to create a regex that applies  the follwing criteria
The amount begins with a £ symbol.
The amount either has no decimals, or just two, as in £9 or £9.11.
Commas appear every three digits to correctly separate thousands, millions, billions, etc., as in £4,444,666.89

0
Question by:Slimshaneey
• 2

LVL 84

Accepted Solution

ozo earned 350 total points
^£\d(1,3)(,\d{3})*(\.\d\d)?\$
0

LVL 74

Assisted Solution

käµfm³d   👽 earned 150 total points
I'm pretty sure ozo meant:

^£\d{1,3}(,\d{3})*(\.\d\d)?\$                            <<===  curly braces around 1,3
0

LVL 84

Expert Comment

Yes, that's what I meant
0

LVL 11

Author Closing Comment

Thanks for the help, thats exactly what Im looking for. Hope the points split is acceptable?
0

## Featured Post

### Suggested Solutions

Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…