Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #escape #chars #regex
ADD COMMENT
Topic
Name
8+6 =