U4-7862 Brackets cause issues in the stylesheet editor

This commit is contained in:
Claus
2016-03-29 14:29:27 +02:00
parent 08070e319a
commit c427c51053
2 changed files with 25 additions and 1 deletions

View File

@@ -1380,6 +1380,30 @@ namespace Umbraco.Core
*/
}
public static string EscapeRegexSpecialCharacters(this string text)
{
var regexSpecialCharacters = new Dictionary<string, string>
{
{".", @"\."},
{"(", @"\("},
{")", @"\)"},
{"]", @"\]"},
{"[", @"\["},
{"{", @"\{"},
{"}", @"\}"},
{"?", @"\?"},
{"!", @"\!"},
{"$", @"\$"},
{"^", @"\^"},
{"+", @"\+"},
{"*", @"\*"},
{"|", @"\|"},
{"<", @"\<"},
{">", @"\>"}
};
return ReplaceMany(text, regexSpecialCharacters);
}
public static bool ContainsAny(this string haystack, IEnumerable<string> needles, StringComparison comparison = StringComparison.CurrentCulture)
{
if (haystack == null) throw new ArgumentNullException("haystack");