4

我试图找到一个匹配以下字符串的正则表达式:

##Content##
##AnotherArea##

到目前为止我已经尝试过

@"\\#\\#(.*?)\\#\\#"
@"\\#\\#(*?)\\#\\#"

但是在运行时似乎都没有找到任何东西:

foreach (var match in Regex.Matches(txtPageContent.Text, expressionMatch))

其中表达式匹配是包含表达式的字符串。

谁能帮我解决这个问题?

4

1 回答 1

5

没必要逃跑#

##.*?##

简单的解释

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 «##»
于 2012-10-11T06:05:23.100 回答