fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8.  
  9.  
  10. String s = @"
  11. hello 'world'
  12. 'foo' bar
  13. 'foo bar'
  14. foo 'bar' but gar 'har'
  15. ";
  16.  
  17. String r = Regex.Replace(s, @"'([^']*)'", "'%$1%'");
  18. Console.WriteLine(r);
  19.  
  20.  
  21. }
  22. }
Success #stdin #stdout 0.08s 24544KB
stdin
Standard input is empty
stdout
hello '%world%'
'%foo%' bar
'%foo bar%'
foo '%bar%' but gar '%har%'