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

后端 未结 6 1197
情歌与酒
情歌与酒 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:20

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

    EDIT: update to meet the new requirements (comments) ;)
    EDIT: remove unnecesary qtfier as per Bryan

    ^[0-9]{1,2}([,.][0-9]{1,2})?$
    

提交回复
热议问题