From: William James Date: 2005-02-19T11:19:45+09:00 Subject: Re: Regexp help - Negative lookahead before across word boundaries Phrogz wrote: > Given a string like this: > "this.position.x = foo.bar.whee * jim.jam - yow / this.jorgle" > > I want to match all the global identifiers which are not 'this', and I > 'need' to do so without consuming any other characters. > > This regexp: > /[^.]\b(?!this)[a-zA-Z_]\w*\b/ > works, but it consumes the preceding character. > s="bar this.position.x = foo.bar.whee * jim.jam - yow / this.jorgle" p s.scan( /(?:^|[^.])\b(?!this)([a-zA-Z_]\w*)\b/ ).flatten produces ["bar", "foo", "jim", "yow"]