开发者

need help in understanding javascript code

开发者 https://www.devze.com 2023-03-08 11:47 出处:网络
Can anyone explain me the fo开发者_如何学JAVAllowing piece of code sampleQuery.replace(new RegExp(\"(\"+query+\")\",\"ig\")

Can anyone explain me the fo开发者_如何学JAVAllowing piece of code

sampleQuery.replace(new RegExp("("+query+")","ig")

What is this "ig" stands for?


the i and the g are flags used with Regular Expressions:

g - 'global' matching - ie. gets all matches (the default behaviour is to stop after one match is found. http://www.w3schools.com/jsref/jsref_regexp_g.asp

i - makes the matches case-insensitive. http://www.w3schools.com/jsref/jsref_regexp_i.asp

hth.

0

精彩评论

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