alternation

Regex is behaving lazy, should be greedy

I thought that by default my Regex would exhibit the greedy behavior that I want, but it is not in the following code: Regex keywords = new Regex(@"in|int|into|internal|interface"); var targets = keywords.ToString().Split('|'); foreach (string t in targets) { Match match = keywords.Match(t); Console.WriteLine("Matched {0,...

javascript regex: match altered version of first match with only one expression

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 a...