Re: [pcre-dev] Oniguruma subroutines

Αρχική Σελίδα
Delete this message
Συντάκτης: Philip Hazel
Ημερομηνία:  
Προς: Sheri
Υ/ο: pcre-dev
Αντικείμενο: Re: [pcre-dev] Oniguruma subroutines
On Wed, 21 May 2008, Sheri wrote:

> This pattern (which works) is cited in pcrepattern:
>
> (abc)(?i:\g<-1>)
>
> but the documentation also says that case sensitivity can't be
> controlled in the subroutine call.
>
> so I tried:
>
> (abc)(\g<-1>)
>
> and got a compilation error, that a recursive call could loop
> indefinitely. (?)


To remove the case sensitivity setting, you need

(abc)(?:\g<-1>)

The ?: is important; it is specifying that the second parentheses are
not capturing. Alternatively, try

(abc)(\g<-2>)

The point is that a negative number refers to the nth most recently
opened capturing parentheses. So with (abc)(\g<-1>) you are indeed
making a recursive call to the second set.

I hope that makes sense.

Philip

--
Philip Hazel