I don’t know if this is a general regex issue or how Sublime Text uses the syntax. Basically what I’m trying to do is capture:
{$ifdef foo} … {$end}
where … is within the begin/end patterns. This is not a problem and works as expected UNLESS the begin/end syntax is on the same line and then the “begin” pattern captures into the “end” pattern OR (not sure which) the “end” pattern starts from the “begin” pattern and causes overlapping.
Can anyone suggested a solution? I’ve tried everything I can think of and still not getting it to work.
<dict>
<key>begin</key>
<string>\{\$\b(?i:(if|ifdef|ifndef))\b\s*([^}]+)\}</string>
<key>captures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>comment.macro.pascal</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>comment.macro.value.pascal</string>
</dict>
</dict>
<key>end</key>
<string>\{\$\b(?i:(endif))\b.*\}</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>comment.macro.pascal</string>
</dict>
</dict>
<key>name</key>
<string>meta.scope.conditional.pascal</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>$self</string>
</dict>
</array>
</dict>