! ====================================================================== ! Syntax Highlighting Patterns for NEdit Extended Regular Expressions ! ====================================================================== ! ! Author: Christopher Conrad ! Release: March 3, 2000 (original) ! !----------------------------------------------------------------------- ! NOTE: These patterns WILL ONLY work with NEdit versions 5.1 and latter !----------------------------------------------------------------------- ! ! To load: ! 1. Save this to a file ! 2. Start NEdit using the -import command line option ! ex: nedit -import ! 3. To retain the patterns in your NEdit startup file... ! Preferences -> Save Default... and click "OK". ! ! Abstract: ! These patterns attempt to highlight extended regular expression ! strings for use with NEdit. The patterns are COMPLICATED because ! I made an effort to highlight the syntax as robustly as possible ! (regular expressions are hard enough. If you going to use ! highlighting to make them more readable you don't want wimpy ! patterns.) ! ! Features: ! o Counting Quantifiers are only highlighted if the numbers ! specified are within the range 0-65535. Any number of leading ! zeros are allowed. ! o Character classes properly handle escaped characters, shortcut ! escapes, and numeric escapes to some degree. Character ranges ! and the special characters that if they appear at the very ! beginning or end are handled properly. ! ! Limitations: ! o Escaped characters, shortcut escapes, and numeric escapes within ! character classes are not distinguished with a subpattern style. ! It was just to complicated. ! o Multiple quantifiers in a row are highlighted even though this ! would be an error. ! o These patterns do not recognize replacement string syntax, ! e.g. "&". ! o All patterns are pass-1 except "Match Themselves". This ! shouldn't be a problem since I don't expect this to be used on 4 ! MB regex files (knock-on-wood). ! o These patterns are for "raw" regex syntax. If used for macro or ! .nedit file regex specifications, the doubled backslashes (\\) ! confuses theses patterns. ! nedit.highlightPatterns:\ regex:1:0{\n\ Comments:"(?#This is a comment!)\\(\\?#[^)]*(?:\\)|$)":::Comment::\n\ Literal Escape:"(?#Special chars that need escapes)\\\\[abefnrtv()\\[\\]<>{}.|^$*+?&\\\\]":::Preprocessor::\n\ Shortcut Escapes:"(?#Shortcuts for common char classes)\\\\[dDlLsSwW]":::Character Const::\n\ Backreferences:"(?#Internal regex backreferences)\\\\[1-9]":::Storage Type::\n\ Word Delimiter:"(?#Special token to match NEdit [non]word-delimiters)\\\\[yY]":::Subroutine::\n\ Numeric Escape:"(?#Negative lookahead is to exclude \\x0 and \\00)(?!\\\\[xX0]0*(?:[^\da-fA-F]|$))\\\\(?:[xX]0*[1-9a-fA-F][\\da-fA-F]?|0*[1-3]?[0-7]?[0-7])":::Numeric Const::\n\ Quantifiers:"(?#Matches greedy and lazy quantifiers)[*+?]\\??":::Flag::\n\ Counting Quantifiers:"(?#Properly limits range numbers to 0-65535)\\{(?:[0-5]?\\d?\\d?\\d?\\d|6[0-4]\\d\\d\\d|65[0-4]\\d\\d|655[0-2]\\d|6553[0-5])?(?:,(?:[0-5]?\\d?\\d?\\d?\\d|6[0-4]\\d\\d\\d|65[0-4]\\d\\d|655[0-2]\\d|6553[0-5])?)?\\}\\??":::Numeric Const::\n\ Character Class:"(?#Handles escapes, char ranges, ^-] at beginning and - at end)\\[\\^?[-\\]]?(?:(?:\\\\(?:[abdeflnrstvwDLSW\\-()\\[\\]<>{}.|^$*+?&\\\\]|[xX0][\\da-fA-F]+)|[^\\\\\\]])(?:-(?:\\\\(?:[abdeflnrstvwDLSW\\-()\\[\\]<>{}.|^$*+?&\\\\]|[xX0][\\da-fA-F]+)|[^\\\\\\]]))?)*\\-?]":::Character Const::\n\ Anchors:"(?#\\B is the ""not a word boundary"" anchor)[$^<>]|\\\\B":::Flag::\n\ Parens and Alternation:"\\(?:\\?(?:[:=!iInN])|[()|]":::Keyword::\n\ Match Themselves:"(?#Highlight chars left over which just match themselves).":::Text Comment::D\n\ } nedit.languageModes:\n\ regex:.reg .regex:"\\(\\?[:#=!iInN].+\\)":None:Continuous:::