jquery Programming Glossary: regexp.escape
apply !important CSS style using jQuery http://stackoverflow.com/questions/2655925/apply-important-css-style-using-jquery value var priority typeof priority 'undefined' priority '' if priority '' Add priority manually var rule new RegExp RegExp.escape styleName ' s s ' RegExp.escape value ' s ' 'gmi' this.cssText this.cssText.replace rule styleName ' ' value ' ' priority.. 'undefined' priority '' if priority '' Add priority manually var rule new RegExp RegExp.escape styleName ' s s ' RegExp.escape value ' s ' 'gmi' this.cssText this.cssText.replace rule styleName ' ' value ' ' priority ' ' CSSStyleDeclaration.prototype.removeProperty.. return this.removeAttribute a CSSStyleDeclaration.prototype.getPropertyPriority function styleName var rule new RegExp RegExp.escape styleName ' s s ^ s s important s ' 'gmi' return rule.test this.cssText 'important' '' Escape regex chars with RegExp.escape..
Highlight search terms (select only leaf nodes) http://stackoverflow.com/questions/3241169/highlight-search-terms-select-only-leaf-nodes share improve this question See it in action escape by Colin Snover Note if you don't care for you can remove it.. RegExp.escape function text return text.replace . ^ # s g function highlight term base if term return base base document.body var re new.. return text.replace . ^ # s g function highlight term base if term return base base document.body var re new RegExp RegExp.escape term gi ... just use term var replacement span class 'highlight' term span base .contents .each function i el if el.nodeType..
|