I have a possibly large block of text to search for instances of [[...]]
, where the ...
can be anything, including other brackets (though they cannot be nested; the first instance of ]]
after [[
ends the match).
I can think of two ways to match this text:
- Using a non-greedy qualifier:
/\[\[.+?\]\]/
- Using a lookahead:
/\[\[(?:(?!\]\]).)+\]\]/
Is one choice inherently better than the other, from a performance standpoint (I'd say the first is probably more readable)? I recall reading that it's better not to use non-greedy qualifiers, but I cannot find a source for that now.