Hi there
I'm writing a brush for Alex Gorbatchev's Syntax Highlighter to get highlighting for Smalltalk code. Now, consider the following Smalltalk code:
aCollection do: [ :each | each shout ]
I want to find the block argument ":each" and then match "each" every time it occurrs afterwards (for simplicity, let's say every occurrence an not just inside the brackets). Note that the argument can have any name, e.g. ":myArg".
My attempt to match ":each":
\:([\d\w]+)
This seems to work. The problem is for me to match the occurrences of "each". I thought something like this could work:
\:([\d\w]+)|\1
but the right hand side of the alternation seems to be treated as an independent expression, so backreferencing doesn't work.
So my question is: is it even possible to accomplish what I want in a single expression? Or would I have to use the backreference within a second expression (via another function call)?
Cheers.