Reputation: 1501
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
Upvotes: 1
Views: 94
Reputation: 626748
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.
Upvotes: 5