I have this regular expression in c#:
Regex oRegex_ = new Regex("<!-- #BeginEditable \"Body\"[^>]*>(.*)<!-- #EndEditable [^>]*>", RegexOptions.Multiline);
MatchCollection matches_ = oRegex_.Matches(contents);
The variable called ‘contents’ equals this:
<!-- #BeginEditable "Body" -->First String<!-- #EndEditable --><!-- #BeginEditable "Extra" -->Second String<!-- #EndEditable -->
Currently it doesnt seem to grab what i need, which is
'First String'
Instead it grabs
'First String<!-- #EndEditable --><!-- #BeginEditable "Extra" -->Second String<!-- #EndEditable -->'
Can anyone help me solve this using a regular expression? 🙁
Please Note: i will be replacing ‘Body’ to become a variable and then put it all in a loop so i can extract ‘Second String’ by making the variable equal ‘Extra’.
Do a non greedy catch using
*?:Another option is to catch the right character (not
<, but this is less accurate if you allow<s in your body):