Shop OBEX P1 Docs P2 Docs Learn Events
Regular expression, help needed — Parallax Forums

Regular expression, help needed

Jay KickliterJay Kickliter Posts: 446
edited 2011-05-01 09:34 in General Discussion
I'm working on a Textmate bulde for the Prop, using bstc and bstl for compiling and loading. But I really suck at regular expressions. I'm chasing my tail on this bit here:
{	name = 'meta.method.spin';
	match = '^(?i)(pub|pri)\s*(\w+)\s*\|*\s*(\w+, )*';
	captures = {
		1 = { name = 'keyword.other.declaration.spin'; };
		2 = { name = 'entity.name.function.spin'; };
		3 = { name = 'storage.variable.local.spin'; };
	};
},

I can't figure out how to capture 0 to n local variables after the `|' in a method declaration, then there's the return variable also. Any suggestions?

Thanks.

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-05-01 08:42
    Jay, just to clarify, you're using these regular expressions in some kind of scripting language inside TextMate itself, right? I'm not familiar with TextMate, but if I were doing this in Perl, I would capture the entire parameter list with the regex, then use split with a \s*,\s* pattern to break out the parameters into an array.

    What is your final objective? A full parse or just enough to do highlighting?

    -Phil
  • Jay KickliterJay Kickliter Posts: 446
    edited 2011-05-01 09:34
    Thanks Phil, just for highlighting. Unfortunately, it isn't in a scripting language, so I have to do it with just regular expressions.
Sign In or Register to comment.