CSharp examples for System:String Strip
Remove Http from URL String
using System.Text.RegularExpressions; using System.Diagnostics; public class Main{ public static string RemoveHttp(string input) {/*from w w w .ja v a 2 s. co m*/ if (string.IsNullOrWhiteSpace(input)) { return string.Empty; } var result = input; var matches = Regex.Matches(input, @"http[^\s]* ", RegexOptions.Compiled); foreach (Match match in matches) { result = result.Replace(match.Value, ""); } var matches2 = Regex.Matches(result, @"http.*", RegexOptions.Compiled); foreach (Match match in matches2) { result = result.Replace(match.Value, ""); } return result.TrimEnd(); } }