tags:

views:

25

answers:

1

Hi, I need to do a regular expression match in php . the case is that .

2 digits before decimal and 2 digits after decimal.

the problem is that it may and may not have decimal and after decimal digits .

how do i write a expression for this ?

+2  A: 

You can try:

\d{2}(?:\.\d{2})?
codaddict
@codaddict - i got this..but what is ?: trying to do. is it necessary?
pradeep
It is for grouping only, without remembering what is being grouped.
codaddict