Regex lookbehind alternative

165 Views Asked by At

I am looking for regex lookbehind alternative because autodl-irssi doesnt support it.

Here is my current working regex and test string:

https://regex101.com/r/Cg6mPv/1

I think that regex needs the following replacement (mode modifier and positive lookbehind):

(?i)(?<=\s|^|\W)

Highlights every line containing any of these words (no case sensitive):

*update*
*dlc*
*expansion*
*artwork*
*fix*
*keygen*
*goodies*
*guide*
*trainer*

Doesnt highlight if line containts a word (no case sensitive):

*fitgirl*

Appreciate any help!

1

There are 1 best solutions below

0
On BEST ANSWER

The (?<=\s|^|\W) pattern is basically equal to (?<=^|\W) or (?<!\w), a place in string that is either the string start position, or a location immediately preceded with a non-word char (i.e. a char other than a letter, digit or _).

Thus, it makes sense to match a word boundary position that is followed by a word char instead:

\b(?=\w)

This construct is equal to \m or [[:<:]] leading word boundary constructs that are supported by some (not many) regex flavors and just require a word char to appear immediately to the right of them.