Regex Matching numbers with floating point

前端 未结 5 2173
感情败类
感情败类 2020-12-17 16:55

I have this pattern:

[0-9]*\\.?[0-9]

It matches numbers but it also matches 3.5.4 as:

  1. 3.5
  2. .4

How to f

5条回答
  •  情书的邮戳
    2020-12-17 17:41

    Your regex is not anchored. If you want to match lines that contain only numbers and nothing else use:

    ^[0-9]*\.?[0-9]$
    

提交回复
热议问题