:我收到錯誤,當我運行下面::「是不是一個函數」以純的JavaScript
var arg_regex = 'myregex:/^[:a-z0-9\s!\\\/]+$/i';
regex_patt = arg_regex.replace(/^myregex:/,'');
if(regex_patt.test(stringtocheck)){
//good
} else {
//bad
}
錯誤:
regex_patt.test is not a function
pl幫助。無法確定它爲什麼會失敗。
'regex_patt'仍然是一個字符串,它不是一個正則表達式。 –