This doesn't immediately seem like an obvious problem, but the .
character needs to be escaped because you're trying to literally match that character.
This regex, with escaped .
and forward slashes works:
^(nfs:\/\/)(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):([0-9]{4})
The problem was that since each capturing group that matches digits can match as few as one digit or as many as three, the regex engine looked at the first 1
(in 172
), found that it was valid, then tried matching .
(any character) and found the digit 7
, which is not what you want.
In nfs://172.1.1:2049
, the second capturing group in your regex matched the first 1
in the IP address, the .
matched the 7
, the third capturing group matched the 2
.. and so on.
Try it here: https://regex101.com/r/TNXDiQ/1