正则表达式Multiline选项

        string i = @"Live for nothing,
die for something";//多行
        Regex r3 = new Regex("^Live for nothing,\r\ndie for something$");
        Console.WriteLine("r3 match count:" + r3.Matches(i).Count);//1
        Regex r8 = new Regex("^Live for nothing,\r$");
        Console.WriteLine("r8 match count:" + r8.Matches(i).Count);//0
        Regex r9 = new Regex("^Live for nothing,\r$", RegexOptions.Multiline);
        Console.WriteLine("r9 match count:" + r9.Matches(i).Count);//1
       //对于一个多行字符串,在设置了Multiline选项之后,^和$将出现多次匹配。

转载于:https://www.cnblogs.com/ForFreeDom/archive/2010/08/07/1794792.html

你可能感兴趣的:(正则表达式Multiline选项)