Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of PHP's preg_quote?

Tags:

c#

What is the equivalent of PHP's preg_quote?

This is as far as I have gotten for creating a method that extracts text from a string:

    public static string f_get_string_between(string text, string start, string end)
    {
        //both these attempts below throw an unrecognized escape sequence error
        //start = "\Q"+start+"\E";
        //end = "\Q"+end+"\E"; 

        Regex regex = new Regex(start + "(.*?)" + end);
        var v = regex.Match(text);
        text = v.Groups[1].ToString();
        return text;
    }
like image 771
atwellpub Avatar asked Feb 10 '12 21:02

atwellpub


1 Answers

Regex.Escape

like image 96
user1096188 Avatar answered Sep 21 '22 10:09

user1096188