I wrote a script that acts as a syntax highlighter highlighting keywords a certain colour. My issue is that the RegExp expression I am currently using is flawed:
this|var|int|String|Object|is|in
The issue with the script is that words within words will be highlighted for example using the above expression following will occur:
var what[COLOR=“blue”]is[/COLOR]:[COLOR=“Blue”]int[/COLOR] = 0;
int is highlighted correctly however I do not want is to be highlighted. How do I make it so the above list is found with the following conditions:
It can not be part of other letters/numbers/symbols
The only symbols/characters that it can be beside are:
. : ? ( ) { } ! + - * / % ^
Basically it’s a list of exceptions to what can be next to the keyword, on either side of it. How do I implement this? - What is the expression?