I need a regular expression that is matching below criteria
For example : below should be matched
1
1134
1.1
1.4.5.6
Those below should not match:
.1
1.
1..6
You can use
^\d+(\.\d+)*$
See demo
^
- beginning of string \\d+
- 1 or more digits (\\.\\d+)*
- a group matching 0 or more sequences of .
+ 1 or more digits $
- end of string. You can use a non-capturing group, too: ^\\d+(?:\\.\\d+)*$
, but it is not so necessary here.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.