c# - 正则表达式匹配整行文本,不包括 crlf

标签 c# .net regex

如何匹配给定文本的每一行的正则表达式模式?

我正在尝试 ^(.+)$ 但它包含 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/

相关文章:

C# 在新进程启动时引发事件

c# - 如何避免进程从 C# 应用程序窃取焦点?

c# - 您如何从 .NET 对 Thrift HBase 进行身份验证?

c# - System.Exception.Data 属性

.net - EF4 如何在事务中包装 2 个更新

regex - 限制单词长度的 Perl 正则表达式

c# - Xamarin IOS UITableViewController RowSelected 导航到 UIViewController

Python re.sub 仅更改单词 'a',而不是将 'a' 的每个实例更改为字母

regex - 您在正则表达式中使用过 Perl 5.10 回溯控制动词吗?

c# - 按照特定模式生成唯一 ID,例如 C# 中的 "digitStringDigit"