Is there any elegant solution to build a variable length look-behind regex such as this one ?
/(?<=eat_(apple|pear|orange)_)today|yesterday/g;
Blog post found today, linked to me at #regex @ irc.freenode.org:
http://www.drregex.com/2019/02/variable-length-lookbehinds-actually.html
This article explains how to do a variable width look-behind in PCRE.
The solution would then be:
/(?=(?=(?'a'[\s\S]*))(?'b'eat_(?:apple|pear|orange)_(?=\k'a'\z)|(?<=(?=x^|(?&b))[\s\S])))today|yesterday/g
https://regex101.com/r/9DNpFj/1