Solved

Pseudo currency regex validation

Posted on 2014-12-30
1
130 Views
Last Modified: 2014-12-30
I need to validate positive currency values under $100, allowing the user to optionally leave out the decimal place. The dollar sign and comma are not needed (or allowed). Another validation component constrains the upper and lower values, so the regex expression only needs to validate 1 or 2 digits, with an optional decimal and 2 more digits.

These values would match:

10
5
5.00
10.00

These values would not match:

.25
10.1
10.255

What is the optimal regex pattern for this validation?
0
Comment
Question by:lynnwalker
1 Comment
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 40524288
^\d\d?(\.\d\d)?$
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Populate Serial Number range 33 71
Need some help with grep 7 82
Coldfusion RegEx 8 49
Regular expressions Exclude patter 3 13
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…
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…
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…

760 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

23 Experts available now in Live!

Get 1:1 Help Now