我正在尝试找到一个与以下字符串匹配的正则表达式:
##Content##
##AnotherArea##
Run Code Online (Sandbox Code Playgroud)
到目前为止我已经尝试过了
@"\\#\\#(.*?)\\#\\#"
@"\\#\\#(*?)\\#\\#"
Run Code Online (Sandbox Code Playgroud)
但是在跑步时似乎都找不到任何东西:
foreach (var match in Regex.Matches(txtPageContent.Text, expressionMatch))
Run Code Online (Sandbox Code Playgroud)
表达式匹配是包含表达式的字符串.
任何人都可以帮我解决这个问题吗?
没有必要逃脱#.
##.*?##
Run Code Online (Sandbox Code Playgroud)
简单的解释
Options: ^ and $ match at line breaks
Match the characters “##” literally «##»
Match any single character that is not a line break character «.*?»
Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?»
Match the characters “##” literally «##»
Run Code Online (Sandbox Code Playgroud)