生成安全的正则字符串
@param {string} str
@returns {string}
165475
function escapeRegExp(str) {
  if (str && str.toString) str = str.toString();
  if (typeof str !== 'string' || !str.length) return '';
  return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
}
591365
function(_str, _args) {
      for(var i = 0; _args && i < _args.length; i++) {
        _str = _str.replace('$' + (i+1), _args[i]);
      }
      return _str;
    }
1242912
private static final String unescape(String str) {
        StringBuilder sb = new StringBuilder(str.length() * 2);
        int len = str.length();
        for (int i = 0; i < len; i++) {
            char c = str.charAt(i);
            if ((c == '\\') && (i < len - 1)) {
                char d = str.charAt(i + 1);
                if (!((d == USER_DATA_DELIM) || (d == USER_ATTRIB_DELIM) || (d == TOKEN_DELIM))) {
                    // if next char is delim, skip this escape char
                    sb.append(c);
                }
            } else {
                sb.append(c);
            }
        }
        return sb.toString();
    }
583285
private String replaceScriptEscapeAndNewLines(String str) {
        StringBuilder result = new StringBuilder(str.length());
        char c = '\0';
        char prevC = '\0';
        boolean atEscape = false;
        for (int i = 0; i < str.length(); i++) {
            prevC = c;
            c = str.charAt(i);
            // set atEscape flag
            if (c == '\\') {
                // deal with 2nd '\\' char
                if (atEscape) {
                    result.append(c);
                    atEscape = false;
                    // set c to '\0' so that prevC doesn't match '\\'
                    // the next time round
                    c = '\0';
                } else {
                    atEscape = true;
                }
            } else if (atEscape) {
                if (c == 'n') {
                    result.append("\n");
                } else {
                    result.append(c);
                }
            } else {
                result.append(c);
            }
            // unset atEscape flag if required
            if (prevC == '\\') {
                if (atEscape) {
                    atEscape = false;
                }
            }
        }
        return result.toString();
    }
536295
function parseRegExp (str) {
  if (str instanceof RegExp) return str
  let arg = String(str).match(/^\/(.*)\/(g|i|)$|.*/)
  return new RegExp(arg[1] || arg[0], arg[2])
}
787845
function string (str, quote) {
    if (this.typecheck) t.typecheck('string', [str, quote]);
    return this.wrap(this.escape(str), quote);
}
315802
function escapeString(str) {

    if(str === undefined) {
        throw new Error('\'str\' is required');
    }

    if(str === null) {
        throw new Error('\'str\' must not be null');
    }

    if(typeof str !== 'string') {
        throw new Error('\'str\' must be a string');
    }

    /*
     * Need to escape backslashes (\) first because escaping ' and " will also 
     * add a \, which interferes with \ escaping.
     */
    var escaped_str = str;
    // regex replace all \ to \\
    escaped_str = escaped_str.replace(/\\/g, '\\\\');
    // regex replace all ' to \'
    escaped_str = escaped_str.replace(/'/g, '\\\'');
    // regex replace all " to \"
    escaped_str = escaped_str.replace(/"/g, '\\"');

    return escaped_str;

}
855726
function strCompact(str) {
        return this.trim(str).replace(/([\r\n\s])+/g, function (match, whitespace) {
            return whitespace === '　' ? whitespace : ' ';
        });
    }
44604
public static String createUnquotedConstant(String str) {
        if (str == null || str.isEmpty()) {
            return str;
        }
        if (str.startsWith("\"")) {
            str = str.substring(1);
        }
        if (str.endsWith("\"")) {
            str = str.substring(0,
                                str.length() - 1);
        }
        return str;
    }
913079
public static String unescape(String str, char escape)
    {
        if (str == null) {
            return "";
        }
        StringBuffer buf = new StringBuffer();
        char[] array = str.toCharArray();
        boolean escaped = false;
        for (int i = 0; i < array.length; i++) {
            char ch = array[i];
            if (escaped) {
                buf.append(ch);
                escaped = false;
            } else {
                escaped = (ch == escape);
                if (!escaped) {
                    buf.append(ch);
                }
            }
        }
        return buf.toString();
    }
444863
function( str ) {
        return str
            // Replaces any - or _ characters with a space
            .replace( /[-_]+/g, ' ')
            // Removes any non alphanumeric characters
            .replace( /[^\w\s]/g, '')
            // Uppercases the first character in each group
            // immediately following a space (delimited by spaces)
            .replace( / (.)/g, function($1) { return $1.toUpperCase(); })
            // Removes spaces
            .replace( / /g, '' );
    }
387050
function strRepeat(str, n) {
    var res = '';
    do {
        if (n & 1) {
            res += str;
        }

        str += str;
    } while (n = n >> 1);

    return res;
}
121670
function strToDate(str) {
  var tempStrs = str.split(" ");
  var dateStrs = tempStrs[0].split("-");
  var year = parseInt(dateStrs[0], 10);
  var month = parseInt(dateStrs[1], 10) - 1;
  var day = parseInt(dateStrs[2], 10);
  if (tempStrs.length > 1) {
    var timeStrs = tempStrs[1].split("-");
    var hour = parseInt(timeStrs [0], 10);
    var minute = parseInt(timeStrs[1], 10) - 1;
    var second = parseInt(timeStrs[2], 10);
    return new Date(year, month, day, hour, minute, second);
  }

  return new Date(year, month, day);
}
87669
private static String cleanString(String str)
    {
	String result = str;
	result = result.replace("\r", "");
	result = result.replace("\n", "");
	result = result.replace("\t", "");

	return result;
    }
67099
function(str){
    if(_.isUndefined(str))
        str = '00';
    
    return String(str).length % 2 ? '0' + String(str) : String(str);
}
549472
public static String quote(String str) {
        int len = str.length();
        StringBuffer buf = new StringBuffer(len+2);
        buf.append("\"");
        char c;
        for (int i=0;i<len;i++) {
            c = str.charAt(i);
            if (c == '"' || c == '\\') {
                buf.append("\\");
            }
            buf.append(c);
        }
        buf.append("\"");
        return buf.toString();
    }
184164
function (str) {
    if (caches[str]) {
      return caches[str];
    }
    
    // special regexp chars (., +, etc.)
    reg = str.replace(/[.+^$()|{}]/g, function (match, offset, s) {
      return s[offset - 1] === '\\' ? match : '\\' + match;
    });
    // ? and *
    reg = reg.replace(/[?*]/g, function (match, offset, s) {
      if (s[offset - 1] === '\\') {
        return match;
      }
      return match === '?' ? '.' : '.*';
    });
    // special regexp escapings (\d, \S, etc.)
    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
    reg = reg.replace(/\\([dDsSwWtrnvfbB0cxu])/g, '$1');
    return caches[str] = new RegExp('^' + reg + '$');
  }