Re: [pcre-dev] Some words about assertion docs

Kezdőlap
Üzenet törlése
Szerző: ph10
Dátum:  
Címzett: ND
CC: Pcre-dev
Tárgy: Re: [pcre-dev] Some words about assertion docs
On Fri, 21 Jun 2019, ND via Pcre-dev wrote:

> Imagine that we have a text. There are some words in this text that occurs at
> least 10 times. We want to find from they a word that is most closer to the
> end of text.
>
> If lookahead assertion is non-possessive then we can use this pattern:
>
> \A(?=.*\b(\w++))(?>.*?\b\1\b){10}
>
> What pattern can solve this task with current PCRE2?


/\A.*\b(\w++)(?>.*?\b\1\b){9}/

You do not need a lookahead to do this.

Philip

--
Philip Hazel