Pattern in lookbehind

后端 未结 3 1380
予麋鹿
予麋鹿 2021-01-22 07:22

My question is related with lookbehinds, I want to find all the first numbers after the word \"this\", I have the following data:

188282 this is an exam

3条回答
  •  北海茫月
    2021-01-22 08:07

    The thing with lookbehinds is that not all languages support variable width lookbehinds (they can't support lookbehinds where what's inside can be of variable number of characters).

    What you can do, might be using a lookahead and a capture group:

    (?=this[^\d]+(\d+))
    

    regex101 demo

    Or maybe the \K regex character which resets a match (if your regex engine supports it).

    this[^\d]+\K\d+
    

    regex101 demo

提交回复
热议问题