Regular expression to verify that string contains a separator comma ( , ) but not a point ( . )

715 Views Asked by At

I'm using SoapUI and I have responses of JSON which contains strings.

For example about string "84,96". I need to create a regular expression which verifies that all value decimals of this JSON are containing a comma (,) but not a point (.)

Examples:
"84,96" is Good
"84.96" is wrong

2

There are 2 best solutions below

0
On
^(\d+?,?\d+)$

this solves your question test here Test

0
On

Numbers

84,96 <-- good
84.96 <-- bad

REGEXEP:

\d+,\d+

Explanation:

\d+ <= All Numbers (84)
,   <= Only Comma  (,)
\d+ <= All Numbers (96)

Result:

84,96

Test Here: https://regex101.com/r/7NNRZy/1