fork(17) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string s = "Woolworth's";
  9. string pattern = "(['^$.|?*+()\\\\])";
  10. string replacement = "\\$1";
  11.  
  12. Regex rgx = new Regex(pattern);
  13. string t = rgx.Replace(s, replacement);
  14.  
  15. Console.WriteLine("Original String: {0}", s);
  16. Console.WriteLine("Replacement String: {0}", t);
  17. }
  18. }
Success #stdin #stdout 0.06s 34136KB
stdin
Standard input is empty
stdout
Original String: Woolworth's
Replacement String: Woolworth\'s