Generation

generate functionMon, 14 Nov 2022

regex check if a string matches a url

public bool IsUrl(string input) { string pattern = @"^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$"; Regex reg = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase); return reg.IsMatch(input); } IsUrl("https://www.google.com");

Want to kickstart your project?Use the new AI Studio to create your code