• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

Regular expression for money

Hi there

So far I have the following regular expression:

£(\d{1,3},)*\d+\.\d{2}

Which will allow monetary values such as £1,000,000.00 but additionally I want to make the .00 on the end optional if a number preceeds it such as 1,000,000 but required if there is no preceeding number i.e. where the user has entered .99 for example.

If anyone knows how to do this I would really appreciate the help.

Many thanks
Sam
0
Samm1502
Asked:
Samm1502
1 Solution
 
oleberCommented:
try:

£((\d{1,3},(\d{3},)*)|\d*)(\.\d\d)?

or give erroneous values
0
 
Samm1502Author Commented:
Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Tackle projects and never again get stuck behind a technical roadblock.
Join Now