I was wondering if it is possible to conditionally enable/disable sections of a replacement string in Sublime Text’s Find/Replace UI.
As an example, I have a find string as follows:
(?x) # Allow comments # IF_P <STAR> (?'if' IF_P ) \s* [*] \s* ( # NOT <STAR> (?'not' NOT ) \s* [*] \s* )? # EXISTS (?'verb' ( EXISTS ) )
What I would like to do is replace matches of that find string with
IF the capture group “NOT” exists, otherwise just
Note that this can’t be done by substituting the “NOT” capture group, as
would result in
in cases where the “NOT” capture group doesn’t exist.
(note the extra underscore)
I’ve tried using Boost-Extended format strings, since I know that Sublime Text does (or did) use Boost’s regular expression syntax, however that doesn’t seem to work.