I’m fairly new to regex and trying to figure out a pattern that will only match the instance of the word inside my custom tag.
In the example below both words match the condition of being after a | and before a ]
Pattern: (?=|)singleline(?=.*])
Sample: [if @sample|singleline second] <p>Another statement singleline goes here</p> [/if]
the
.*, which means “anything, zero or more times, and be greedy about it”, will race to the end of the string and back up only enough to get to a](the last one). (and your lookbehind is a lookahead):if you really want to match what you say you want to match (see quote), then this is it:
Edit: or this one if you want to “match alphanumerics and spaces inside | and ]“: