Based on Tatu Ullman's answer, my solution in C # got the following form:
private static List<string> RegexSpecialCharacters = new List<string> { "\\", ".", "+", "*", "?", "[", "^", "]", "$", "(", ")", "{", "}", "=", "!", "<", ">", "|", ":", "-" }; foreach (var rgxSpecialChar in RegexSpecialCharacters) rgxPattern = input.Replace(rgxSpecialChar, "\\" + rgxSpecialChar);
Note that I switched the positions "\" and ".", Failure to handle slashes first will double the value "\"
hngr18 Jul 26 '17 at 11:16 2017-07-26 11:16
source share