Results 1 to 3 of 3

Thread: [RESOLVED] [RegEx for AS3] RegExp Code Keywords?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    Resolved [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?

  2. #2
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    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.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    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
  •  



Click Here to Expand Forum to Full Width