如何匹配给定文本的每一行的正则表达式模式?
我正在尝试 ^(.+)$
但它包含 crlf...
最佳答案
只需使用 RegexOptions.Multiline .
Multiline mode. Changes the meaning of ^ and $ so they match at the beginning and end, respectively, of any line, and not just the beginning and end of the entire string.
例子:
var lineMatches = Regex.Matches("Multi\r\nlines", "^(.+)$", RegexOptions.Multiline);
关于c# - 正则表达式匹配整行文本,不包括 crlf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5956909/