Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Requirement for regex for currency amounts

Posted on 2009-05-13
4
Medium Priority
?
296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 84

Accepted Solution

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

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 600 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

by Batuhan Cetin Regular expression is a language that we use to edit a string or retrieve sub-strings that meets specific rules from a text. A regular expression can be applied to a set of string variables. There are many RegEx engines for u…
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
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…

598 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