> LçÉettçËäº "Phrogz" <gavin / refinery.com> > Aihe: Regexp help - Negative lookahead before across word boundaries > > 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. > > I thought this regexp would work: > /(?!\.)\b(?!this)[a-zA-Z_]\w*\b/i > but now I realize why it doesn't. (Because the position after the > period satifies the negative lookahead and the word boundary.) I'm assuming 'global identifier' means any sort of a variable label instead of a '$global' identifier (correct if I'm wrong)? You could do two things; first, to circumvent the whole negative lookahead, you could just do: (?:(?:this)|([a-zA-Z_]) And check for a $1 match. If you want to use the negative, I think you have to consume it somehow: (?!this)([a-zA-Z_]+?) Should first ensure that 'this' isn't present, then backtrack and move to the next match segment (which here matches any of those specified characters) *from the same area*. You should be able to vary that basic idea to fit your need. Apparently Oniguruma will include a n-w look-BACK, which'll be a help :) > Help? E