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|