Check this (in C#):
data_string = Regex.Replace( data_string, @"(?<=(?<!\d)(\d{1,3}\.){3}\d{1,3}):(?=\d{1,5}(?!\d))", " port " );
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello everyone,
I have a string that contains some IP and port numbers in this format:
108.177.3.26:25
each block in IP can be from 1 to 3 digits, and port after : can be up to 5 digits (65535)
No need to validate it, just gonna replace all those blocks with something like:
108.177.3.26 port 25
Now:
data string = data string . Replace (":", " port ")
seems the easiest, but will also replace all other : in the source data, any short way to do it?
or need to parse chars before and after :
Thanks for help
Check this (in C#):
data_string = Regex.Replace( data_string, @"(?<=(?<!\d)(\d{1,3}\.){3}\d{1,3}):(?=\d{1,5}(?!\d))", " port " );