Variable length look-behind

后端 未结 5 1153
猫巷女王i
猫巷女王i 2020-12-16 13:38

Is there any elegant solution to build a variable length look-behind regex such as this one ?

/(?<=eat_(apple|pear|orange)_)today|yesterday/g;

5条回答
  •  鱼传尺愫
    2020-12-16 14:04

    How about:

    (?:(?<=eat_apple_)|(?<=eat_pear_)|(?<=eat_orange_))(today|yesterday)
    

    A little bit uggly, but it works.

提交回复
热议问题