how to validate US currency with this format $123.45

I have one one web page which one one textbox for receiving the dollar value. My requirement is the user should insert the digit following by a $ sysmbol. And the second requirement is the user has the permission to insert only like this $123.45. Before the decimal point it should not exceed three digits and after the decimal point it should not exceed two digits. Please help me by providing the appropriate regular expression for validating this value.. thanks in advance.





if you want to force the last decimal to have 2 digits



\$ = a dollar, escaped as it is a special character \d = a digit; {1,3} = between 1 and 3 repetitions ()? = an optional group: \. = a dot (escaped) \d{1,2} = one or two digits

To play regular expressions (and test them) you can use Expresso or a similar tool.

Need Your Help

Using Prettify on dynamically-generated code

javascript css prettify

I'm using Prettify for syntax highlighting, but it doesn't work on dynamically generated code.

Sorting in text file through program in Qt

c++ qt sorting user-interface

I am using Qt5.2.1 and I made a program that stores some values(like name, number, other details...) in a text file. I want to arrange this information according to the name.