Regular expression with C #

I am trying to find a regex that matches the following lines:

##Content## ##AnotherArea## 

So far i tried

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

But nothing finds anything at startup:

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

Where the expression matches the string containing the expression.

Can someone help me with this?

+4
source share
1 answer

no need to run # .

 ##.*?## 

simple explanation

 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 «##» 
+5
source

Source: https://habr.com/ru/post/1439076/


All Articles