William James
2/19/2005 2:19:00 AM
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"]