Code coverage report for string/escapeRegExp.js

Statements: 100% (8 / 8)      Branches: 100% (2 / 2)      Functions: 100% (3 / 3)      Lines: 100% (7 / 7)     

All files » string/ » escapeRegExp.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 191   1           1 2 1   2     1      
define(function () {
 
    var _rEscapeChars;
 
    /**
     * Escape RegExp string chars.
     * @version 0.1.0 (2011/12/17)
     */
    function escapeRegExp(str) {
        if (! _rEscapeChars) {
            _rEscapeChars = /[\\.+*?\^$\[\](){}\/'#]/g;
        }
        return str.replace(_rEscapeChars,'\\$&');
    }
 
    return escapeRegExp;
 
});