How to check a string contains only digits and decimal points?

前端 未结 3 1550
一生所求
一生所求 2021-01-11 09:54

For example I want to check that my when I split my string that the first part only contains numbers and decimal points.

I have done the following

         


        
3条回答
  •  长发绾君心
    2021-01-11 10:25

    You can use this regex:

    \\d+(\\.\\d+)*
    

    Code:

    if(parts_s1[0].matches("\\d+(\\.\\d+)*") {...}
    

提交回复
热议问题