fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var s = @"this is my text here is a link http://d...content-available-to-author-only...f.com and my is /images/dd.gif";
  9. var regex = new Regex(@"\S*/images\S*|(?<!\S)((?:(?:https?|ftp)://)?[\w-]+(?:(?:\.[\w-]+)+)(?:[\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)");
  10. var result = regex.Replace(s, match => match.Groups[1].Success ? "" : match.Value);
  11. Console.WriteLine(result);
  12. }
  13. }
Success #stdin #stdout 0.1s 21500KB
stdin
Standard input is empty
stdout
this is my text here is a link  and my is /images/dd.gif