【发布时间】:2011-06-02 17:33:33
【问题描述】:
为什么下面的 jQuery 代码不起作用?
$(function() {
var regex = /\?fb=[0-9]+/g;
var input = window.location.href;
var scrape = input.match(regex); // returns ?fb=4
var numeral = /\?fb=/g;
scrape.replace(numeral,'');
alert(scrape); // Should alert the number?
});
基本上我有一个这样的链接:
http://foo.com/?fb=4
如何先找到?fb=4,然后只检索号码?
【问题讨论】:
标签: javascript jquery regex replace match