From 0e377c1affa77efb82d923847bfc6096169eea21 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Sat, 6 Oct 2012 15:43:23 +0100 Subject: [PATCH] New regex for efficiency More specific regex used to ensure efficiency & speed are optimal Syntax spacing adjusts on couple of other lines --- lib/coder.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/coder.js b/lib/coder.js index 864c4ce..ce23c2d 100644 --- a/lib/coder.js +++ b/lib/coder.js @@ -1304,13 +1304,13 @@ var ICEcoder = { // Show a CSS color block next to our text cursor cssColorPreview: function() { - var cM,string,rx,match,oldBlock,newBlock; + var cM, string, rx, match, oldBlock, newBlock; cM = ICEcoder.getcMInstance(); string = cM.getLine(cM.getCursor().line); - rx = /(#[\da-f]{3,6}\b|(?:rgb|hsl)a?\([^)]*\)|[a-z]+\b)/gi; + rx = /(#[\da-f]{3}(?:[\da-f]{3})?\b|\b(?:rgb|hsl)a?\([\s\d%,.-]+\)|\b[a-z]+\b)/gi; - while((match = rx.exec(string)) && cM.getCursor().ch > match.index + match[0].length); + while((match = rx.exec(string)) && cM.getCursor().ch > match.index+match[0].length); oldBlock = top.document.getElementById('content').contentWindow.document.getElementById('cssColor'); if (oldBlock) {oldBlock.parentNode.removeChild(oldBlock)};