Matching numbers with regular expressions — only digits and commas

前端 未结 10 1467
旧时难觅i
旧时难觅i 2020-11-22 08:07

I can\'t figure out how to construct a regex for the example values:

123,456,789
-12,34
1234
-8

Could you help me?

10条回答
  •  囚心锁ツ
    2020-11-22 08:24

    In java, You may use java.util.Scanner with its useLocale method

    Scanner myScanner =  new Scanner(input).useLocale( myLocale)
    
    isADouble = myScanner.hasNextDouble()
    

提交回复
热议问题