On Sunday 12 September 2004 06:54, Andrew Johnson wrote: > On 12 Sep 2004 03:44:24 GMT, Phil Tomson <ptkwt / aracnet.com> 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. irb(main):007:0> re = NewRegexp.new('(?=.z).(?<=(?:ab){2,3}x.)') => +-Sequence +-Lookahead positive | +-Sequence | +-Outside set=U-000A | +-Inside set="z" +-Outside set=U-000A +-Lookbehind positive +-Sequence +-Repeat greedy{2,3} # quantifier inside lookbehind!! | +-Group non-capturing | +-Sequence | +-Inside set="a" | +-Inside set="b" +-Inside set="x" +-Outside set=U-000A irb(main):008:0> 'xyz'.gsub5(re, 'Y') => "xyz" irb(main):009:0> 'abxyz'.gsub5(re, 'Y') => "abxyz" irb(main):010:0> 'ababxyz'.gsub5(re, 'Y') => "ababxYz" irb(main):011:0> 'abababxyz'.gsub5(re, 'Y') => "abababxYz" -- Simon Strandgaard