Simple regular expression for a decimal with a precision of 2

What is the regular expression for a decimal with a precision of 2?

Valid examples:


Invalid examples:


The decimal point may be optional, and integers may also be included.


Valid regex tokens vary by implementation. The most generic form that I know of would be:


The most compact:


Both assume that you must have both at least one digit before and one after the decimal place.

To require that the whole string is a number of this form, wrap the expression in start and end tags such as (in Perl's form):


ADDED: Wrapped the fractional portion in ()? to make it optional. Be aware that this excludes forms such as "12." Including that would be more like ^\d+\.?\d{0,2}$.

Need Your Help

How to write hbm.xml for given three tables

java hibernate

Here I am trying to create hibernet mapping between three tables.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.