[英]regex matches \n in c#
我需要轉義特殊字符,因此我已經檢查了如下正則表達式選項,即new Regex(@"^[\\w@.-]*$",RegexOptions.Compiled); 對於\\ n以外的所有特殊字符,它都工作正常,因此我如何檢查所有特殊字符。
new Regex(@"^[\\w@.-]*$",RegexOptions.Compiled);
使用否定的超前斷言:
^[\\w@.-]*(?!\\n)$
演示
[英]Regex that matches a newline (\n) in C#
[英]Multiple Regex matches in C#
[英]REGEX matches in tester but not C#
[英]C# Enumerate Regex Matches
[英]c# regex matches example
[英]Regex matches in C# but not in java
[英]regex matches with intersection in C#
[英]Regex (C#): Replace \n with \r\n
[英]C#: Regex Replace Matches after Conversion
[英]Getting overlapping regex matches in C#
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.