kalls
kalls

Reputation: 2855

Regular Expression for number and special characters

I have the following regex

^\d+(\,\.\d+)?$

I am trying to match the following

  1. 23
  2. 23.45
  3. 1,156
  4. 12,523
  5. 1.24
  6. 1.1

my expression does not work and I am looking for suggestions. Thank you!

Upvotes: 0

Views: 897

Answers (1)

Joop Eggen
Joop Eggen

Reputation: 109547

^\d+([,.]\d+)?$

You had a sequence of comma and period, not a group.

Upvotes: 1

Related Questions