[TxMt] Help with RegEx in Bundles

Edmundo Ortega ed at westernfreight.com
Thu Jun 16 17:25:12 UTC 2005


Hi, I'm modifying the default actionscript bundle and I have a regex  
question that I haven't been able to figure out.

I want to match a function declaration, but I don't want to capture  
the arguments of the function. In other words, in a function like this:

public function addItem(name: String, item: MenuItem): Void {
     // ...
}

I want to color

"addItem(" and ")"

but not

"name: String, item: MenuItem

Is this possible in one regex expression? Is there some way to match  
something by looking for a leading (or trailing) indicator without  
including the indicator in the match? In other words... something like:

[in pseudocode] find ")" preceded by "function [a-zA-Z_]* ( ^)"

I'm currently using this regex to successfully capture the whole thing:

match = "\\b(function)\\s+([a-zA-Z_]\\w*)\\s*\\([^\\)]*\\)";

Thanks for the help!

Ed



More information about the textmate mailing list