1. public struct Strep
    2. {
    3. public string Patstr { get; set; }
    4. public string Repstr { get; set; }
    5. }
    6. public static string GetMTextRegstr(string input)
    7. {
    8. string tXTstr = input;
    9. List<Strep> replst = new List<Strep>()
    10. {
    11. new Strep(){Patstr= @"\\\\" ,Repstr=((char)1).ToString()},
    12. new Strep(){Patstr= @"\\{" , Repstr=((char)2).ToString()},
    13. new Strep(){Patstr= @"\\}" , Repstr=((char)3).ToString()},
    14. new Strep(){Patstr= @"\\pi(.[^;]*);" , Repstr=""},
    15. new Strep(){Patstr= @"\\pt(.[^;]*);" , Repstr=""},
    16. new Strep(){Patstr= @"\\S(.[^;]*)(^|#|\\)(.[^;]*);" , Repstr=""},
    17. new Strep(){Patstr= @"(\\F|\\f|\\C|\\H|\\T|\\Q|\\W|\\A)(.[^;]*);" , Repstr=""},
    18. new Strep(){Patstr= @"(\\L|\\O|\\K|\\l|\\o)" , Repstr=""},
    19. new Strep(){Patstr= @"\\~" , Repstr=""},
    20. new Strep(){Patstr= @"\\pse1;" , Repstr=""},
    21. new Strep(){Patstr= @"\\pql;" , Repstr=""},
    22. new Strep(){Patstr= @"\\pqc;" , Repstr=""},
    23. new Strep(){Patstr= @"\\pqr;" , Repstr=""},
    24. new Strep(){Patstr= @"\\pxqc;" , Repstr=""},
    25. new Strep(){Patstr= @"({|})" , Repstr=""},
    26. new Strep(){Patstr= @"\x01" , Repstr=@"\\\\"},
    27. new Strep(){Patstr= @"\x02" , Repstr="{"},
    28. new Strep(){Patstr= @"\x03" , Repstr="}"}
    29. };
    30. foreach (Strep sr in replst)
    31. {
    32. tXTstr = Regex.Replace(tXTstr, sr.Patstr, sr.Repstr);
    33. }
    34. return tXTstr;
    35. }