Commit 46eb5fe3 authored by Zéfling's avatar Zéfling 🎨
Browse files

Forgot file

parent cd62d5da
/**
* Protec a string for RegExp
* @param string to transform
* @return protected string
*/
RegExp._protect = function(string) {
return new String(string).replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
};
/**
* Tranform to regex string
* @param obj a string or array (['1', '2'] -> '1|2');
* @return protected string
*/
RegExp._toRegexString = function (obj) {
var str;
if (!baku.isArray(obj)) {
str = RegExp._protect(obj);
}
else {
var i = 0, l = obj.length;
for (; i< l; i++) {
obj[i] = RegExp._protect(obj[i]);
}
str = obj.join('|')
}
return str;
};
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment