|
-
May 7th, 2011, 11:35 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] [RegEx for AS3] RegExp Code Keywords?
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:
Code:
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 whatis:int = 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?
-
May 11th, 2011, 12:08 PM
#2
Re: [RegEx for AS3] RegExp Code Keywords?
Something like...
Code:
\b (this|var|int|String|Object|is|in) (?!\w)
\b specifies to match a word boundary, and the (?!\w) specifies that what you matched should not be followed by another word character.
-
May 11th, 2011, 09:38 PM
#3
Thread Starter
Frenzied Member
Re: [RegEx for AS3] RegExp Code Keywords?
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|