下面是一个简单的代码片段,演示了.Net正则表达式中行尾匹配("$")的看似错误的行为.我错过了一些明显的东西吗
string input = "Hello\nWorld\n";
string regex = @"^Hello\n^World\n"; //Match
//regex = @"^Hello\nWorld\n"; //Match
//regex = @"^Hello$"; //Match
//regex = @"^Hello$World$"; //No match!!!
//regex = @"^Hello$^World$"; //No match!!!
Match m = Regex.Match(input, regex, RegexOptions.Multiline | RegexOptions.CultureInvariant);
Console.WriteLine(m.Success);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
197 次 |
| 最近记录: |