From: Simon Strandgaard Date: 2004-09-12T20:32:11+09:00 Subject: Re: look-behind in oniguruma On Sunday 12 September 2004 13:07, Simon Strandgaard wrote: > On Sunday 12 September 2004 06:54, Andrew Johnson wrote: > > On 12 Sep 2004 03:44:24 GMT, Phil Tomson wrote: > > > Apparently oniguruma supports look-behind. Is there any documentation > > > on how to use this feature? > > > > Essentially, they are the same as look-aheads ... zero-width assertions, > > except that the look-behind expression must be a fixed width pattern (no > > indeterminate quantifiers), and no captures are allowed in a negative > > look-behind > > Oniguruma supports alternation inside lookbehind, so you can get a similar > behavior as quantifiers. > > AEditor's regexp engine supports variable width lookbehind, where you > can use quantifiers inside lookbehind.. (with inversed left-most-longest > rule). > > It would be good if Oniguruma had support for quantifiers inside > lookbehind. (here is an example with infinite quantifiers) irb(main):016:0> re = NewRegexp.new('(? +-Sequence +-Lookbehind negative | +-Alternation | +-Repeat greedy{1,-1} | | +-Group capture=1 | | +-Sequence | | +-Inside set="a" | | +-Inside set="b" | +-Repeat greedy{2,-1} | +-Group capture=2 | +-Sequence | +-Inside set="c" | +-Inside set="d" +-Outside set=U-000A irb(main):017:0> 'qwerty'.gsub5(re, 'Z') => "ZZZZZZ" irb(main):018:0> 'qweabrty'.gsub5(re, 'Z') => "ZZZZZrZZ" irb(main):019:0> 'cdcdqwerty'.gsub5(re, 'Z') => "ZZZZqZZZZZ" irb(main):020:0> 'cdqwerty'.gsub5(re, 'Z') => "ZZZZZZZZ" irb(main):021:0> -- Simon Strandgaard