Let's start with little example; I have the following text:
[[ some tag [[ with tag nested ]] and again ]]
I'd like to match [[ with tag nested ]] but not [[ some tag [[ with tag nested ]] . Simple
\[\[(?<content>.+?)\]\]
obviously didn't work. So I created regexp:
\[\[(?!.*?\[\[.*?\]\].*?)(?<content>.+?)\]\]
Unfortunately it doesn't match anything using C# (with MatchOptions.SingleLine), while PHP's preg_match works perfectly.
Any clues/ideas? Any help would be much appreciated.
System.Text.RegularExpressions.Regexusing your second pattern and theRegexOptions.Singlelinethen calledMatchon your example string. It came back with one capture of "[[ with tag nested ]]".[[ outer1 [[ nested1 ]] outer2 [[ nested2 ]] outer3 ]]. If I understand the question correctly, it should matchnested1andnested2, but it only matchesnested2.