开发者

need help in understanding javascript code

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜