How to validate numeric values which may contain dots or commas?

后端 未结 6 1193
情歌与酒
情歌与酒 2020-12-13 05:31

I need a regular expression for validation two or one numbers then , or . and again two or one numbers.

So, these

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-13 06:32

    \d{1,2}[,.]\d{1,2}
    

    \d means a digit, the {1,2} part means 1 or 2 of the previous character (\d in this case) and the [,.] part means either a comma or dot.

提交回复
热议问题