code_junkie

Why is this regular expression faster?

Nov 10th, 2011
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. public static string StripStringFormating(string formattedString)
  2. {
  3. if (rTest.IsMatch(formattedString))
  4. return rTest.Replace(formattedString, string.Empty);
  5. else
  6. return formattedString;
  7. }
  8.  
  9. static Regex rText = new Regex(@"e[[d;]+m", RegexOptions.Compiled);
  10.  
  11. static Regex rTest =
  12. new Regex(@"(e([([d;]*[mz]?))?)?", RegexOptions.Compiled);
  13.  
  14. "(e[(d{1,2};)*?[mz]?)?"
  15.  
  16. public static string StripStringFormating(string formattedString)
  17. {
  18. return rTest.Replace(formattedString, string.Empty);
  19. }
  20.  
  21. (?s)(?:e[(?:(d+);?)*([A-Za-z])(.*?))(?=e[|z)
  22.  
  23. <ESC>[1;32mThis is bright green.<ESC>[0m This is the default color.
  24.  
  25. [ [1, 32], m, This is bright green.]
  26. [0, m, This is the default color.]
Add Comment
Please, Sign In to add comment