cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Restrict text field to accept only numbers and dots

Hi I would like to restrict the field with numbers and dots(.) using RegEx expressions.

Please guide me. For example, this is actually an IP Address

10.111.123.23
10.111.151.150

Labels: (2)
0 Kudos
Reply
3 Replies
Workflow Hero

Re: Restrict text field to accept only numbers and dots

try eg.

^(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})(\.(?!$)|$)){4}$
Accept as Solution Reply
Workflow Hero

Re: Restrict text field to accept only numbers and dots

Hi Marian

It should not accept this also, please refer below screen shot. The above regex is accepting two digits after first dot/decimal, it should not accept. The format should be like this. xx.xxx.x/xx/xxx.x/xx/xxx . Here "/" is OR.

What about this - ^([0-9]{2}.[0-9]{3}.[0-9]{1,3}.[0-9]{1,3})$

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Restrict text field to accept only numbers and dots

then I'd define the pattern like follows

^[0-9]{2}\.(25[0-5]|2[0-4][0-9]|[01][0-9]{2})\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})$

your pattern would match as well input like 10.999.999.999 which is not valid IP address ...

0 Kudos
Accept as Solution Reply