From: ptkwt@... (Phil Tomson) Date: 2004-09-12T14:54:57+09:00 Subject: Re: look-behind in oniguruma In article , Andrew Johnson wrote: ^^^^^^^^ hmmm... >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 > >> for example, if I had the string "~ABC~DE" and I want to return a list of >> letters in the string which are preceeded by '~' ( ['A','D'] in this case) how >> might I use the look-behind feature in oniguruma to achieve this? or, how >> would I get a list of letters in the string which are not preceeded by '~' >> (['B','C', 'E'] in this example. > > > str = "~ABC~DE" > p str.scan(/(?<=~)[A-Z]/) > p str.scan(/(? >gives: > > ["A", "D"] > ["B", "C", "E"] > Thanks. That's what I was looking for. Is this essentially the same way that it works in Perl? Phil