C# extract ip address from url
using System.Text.RegularExpressions; static void ExtractIpDemo() { string url = "192.125.35.48\\d\\subfolder\\bsubfolder\\cfolder\\d.txt"; string ipValue = ExtractIPAddressFromUrl(url); Console.WriteLine(ipValue); } static string ExtractIPAddressFromUrl(string remoteAddress) { string ipHost = string.Empty; var match = Regex.Match(remoteAddress, @"\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b"); if (match.Success) { ipHost = match.Captures[0].Value; } return ipHost; }