RegEx validation of decimal numbers with comma or dot
Try This,
/^(\d+(?:[\.\,]\d{1,2})?)$/
pat = re.compile('^\d+([\.,]\d\d)?$')
re.match(pat, '1212')
<_sre.SRE_Match object at 0x91014a0>
re.match(pat, '1212,1231')
None
re.match(pat, '1212,12')
<_sre.SRE_Match object at 0x91015a0>
Try this regex:
/^(\d+(?:[\.\,]\d{2})?)$/
If $1
exactly matches your input string then assume that it is validated.