> Hi Benjohn,
>
> Am Mittwoch, 13. Dez 2006, 18:24:08 +0900 schrieb benjohn / fysh.org:
>> Eg, to scan for variables called x or y, I might use:
>>   /(^|[^a-zA-Z])[xy]([^a-zA-Z]|$)/
>>
>> but using that on "exp(x)" will match (and replace) "(x)", which I
>> don't
>> want at all.
>
> /\b[xy]\b/
>
> The \b pattern (word boundary) will look to the left like the ^ pattern
> does.

This seems like the best approach in this case, as it's a good enough
way to find variables. It does break down in the complex case though.

> I would appreciate if there were a general pattern looking to the left
> corresponding to (?=re) what is non-consuming to the right.

The book I'm reading (o'reilly pocket reference) hints at the look
arround constructs being:

  (?=...) - look ahead.
  (?!...) - negated look ahead.
  (?<=...) - look behind.
  (?<!...) - negated look behind.

So perhaps one of those is what you want?