Solved

Requirement for regex for currency amounts

Posted on 2009-05-13
4
290 Views
Last Modified: 2012-05-06
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
Comment
Question by:Slimshaneey
  • 2
4 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 350 total points
ID: 24372842
^£\d(1,3)(,\d{3})*(\.\d\d)?$
0
 
LVL 75

Assisted Solution

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

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

Expert Comment

by:ozo
ID: 24373469
Yes, that's what I meant
0
 
LVL 11

Author Closing Comment

by:Slimshaneey
ID: 31580884
Thanks for the help, thats exactly what Im looking for. Hope the points split is acceptable?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been reconstructing a PHP-based application that has grown into a full blown interface system over the last ten years by a developer that has now gone into business for himself building websites. I am not incredibly fond of writing PHP code o…
Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
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…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now