[Ilugc] Reg exp help

  • From: rajanvn@xxxxxxxxx (Natarajan V)
  • Date: Fri Sep 7 21:51:20 2007

On 9/7/07, Suresh Kumar <suresh1876@xxxxxxxxx> wrote:

On 9/7/07, Zico <mailzico@xxxxxxxxx> wrote:

On 9/7/07, Parth <parth.technofreak@xxxxxxxxx> wrote:

On 9/7/07, Suresh Kumar <suresh1876@xxxxxxxxx> wrote:
hi. i need reg exp for validation
to allow
  4.000,00

are you sure.. a 4 followed by . followed by 000 followed by , and
then by 00 ? or is it 4,000.00 ?



yes.. its the price validation in danish
used this one
^[0-9.,]*(\,)[0-9]{2}

Beg to disagree. If I am not wrong, you are trying to validate a
currency and you have got an European client. In most parts of Europe,
DOT and COMMA are interchangeably used. Therefore, 1,000.00 is same as
1.000,00. My Visa entry had an entry with 35,00 meaning 35 Euros.

With this background, the RegEx ^[0-9.,]*(\,)[0-9]{2} will also
validate ",,...28.12" which is incorrect.

The following RegEx which I flicked out of Google searching for
"Regular Expression Currency Validation" and modifying it a little
gives me the following.

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

A couple of  problems though.  Just that it forces you to use the
thousand separator. It will not work for the Indian Number system
(comma after ten thousand).

HTH,

Regards,
Natarajan

Other related posts: