Answers for "escape chars for regex c#"

C#
0

escape chars for regex c#

// Don't actually do this to check containment... it's just a little example.
public bool RegexContains(string haystack, string needle)
{
    Regex regex = new Regex("^.*" + Regex.Escape(needle) + ".*$");
    return regex.IsMatch(haystack);
}
Posted by: Guest on November-02-2021

C# Answers by Framework

Browse Popular Code Answers by Language