JavaScript Regex Syntax Highlighter
这是一个使用正则表达式实现语法高亮的JavaScript库,类似 RegexPal 使用方法如下:
var regexEls = document.getElementsByClassName("regex"),
len = regexEls.length,
el, text, i;
for (i = 0; i < len; i++) {
el = regexEls[i];
text = el.textContent || el.innerText;
// this is where the magic happens
el.innerHTML = highlightJsReSyntax(text);
}
评论