开发者

javascript match: find string matched by match

Using javascript match to check if a $.get request contains a string, how do I get the actual string matched? Ideally the match should only return true if the exact phrase is found. My code:

var word = "My Phrase";
/// data = "My Phrases, string2, another phrase, etc"
var mymatch = data开发者_运维问答.match(word);

I dont want mymatch to match data unless it is an exact match, in this case mymatch should not match any of the data provided.

I was hoping to do an exact match on the data OR get the string matched and check if they were the same. i.e.

if (mymatch == whatwasmatched) { then an exact match was found }

Am I just missing some positioning element in my match or can I find what was matched by match()?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜