开发者

reg exp - search() [duplicate]

开发者 https://www.devze.com 2023-03-26 14:54 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: How do you pass a variable to a Regular Expression Java开发者_开发问答Script?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How do you pass a variable to a Regular Expression Java开发者_开发问答Script?

how to write a variable into a reg exp pattern?

here the pattern always is /value/i

var value = inp.val();
if(search_list[key].search(/value/i) >= 0) alert('ok');


Instead of using the implicit literal syntax you could change to be explicit.

new RegExp(value, "i")
0

精彩评论

暂无评论...
验证码 换一张
取 消