regex
" class. You can see an example of doing just that on my quick and dirty test page.
Highlighting example:
<table\b[^>]*>(?:(?=([^<]+))\1|<(?!table\b[^>]*>))*?</table>
\10
is backreference 10, backreference 1 followed by a literal zero, octal character index 10, or something else altogether due to its position in the surrounding pattern. Speaking of octal escapes (which are de facto browser extensions; not part of the spec.), they are correctly highlighted according to their subtle differences inside and outside character classes (outside of character classes only, octals can include a fourth digit if the leading digit is a zero).
As far as I'm aware, this is the first JavaScript library for highlighting regex syntax, with or without the level of completeness included here. For people who might feel inclined to use or improve upon my work, I've made the licensing as permissive as possible to avoid getting in your way. RegexPal is already open source under the GNU LGPL 3.0 License, but this new library is released under the MIT License. If you plan to customize or help upgrade this code, note that it could probably use a bit of an overhaul (it's ripped from RegexPal with minimal modification), and might require an overhaul if you want to cleanly add support for additional regex flavors. Another nifty feature I plan to eventually add is explanatory title
attributes for each element in the returned HTML, which might be particularly helpful for deciphering any highlighted errors or warnings.
Let me know if this library is useful for you, or if there are any other features you'd like to see added or changed. Thanks!
Link: JavaScript Regex Syntax Highlighter.