View Single Post
  #1 (permalink)  
Old 06-29-09, 02:25 AM
TehBigA TehBigA is offline
Newbie Coder
 
Join Date: Jun 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Problem with multiple expressions

I'm trying to make a fairly simple syntax highlighter that just matches a few things but I'm not sure how to match multiple expressions, such as I don't want to match a number if is within a comment or quoted string.

For example my text:
Code:
// A comment with numbers, 123, and string, "STRING"
Right now I have these expressions:
> Numbers: ~[0-9]+(?:\.[0-9]*)?~m
> Comments: ~(\/\/.*$)|((\/\*[\s\S]*?\*\/))~m
> Strings: ~(?<!\w)(['"])(.*)\1(?!\w)~m
> Special: ~\b(function|local|true|false|if|then|end|for|do|w hile|break|return)\b~m

EDIT: I'm not sure why the forum is putting a space between |while|

Last edited by TehBigA; 06-29-09 at 02:28 AM.
Reply With Quote