Javascript 使用正则表达式在斜杠之间获取值
我要去拿那个 索引/##/ “##”表示数值Javascript 使用正则表达式在斜杠之间获取值,javascript,regex,Javascript,Regex,我要去拿那个 索引/##/ “##”表示数值 我计划运行regex is javascript。您可以使用\/来转义要在正则表达式中使用的斜杠: 因此,结果将是: var input = "http://example.com/...../post/index/88/mike-hey-dddd"; var match = input.match(/\/index\/(\d+)/i); // Make sure to validate the result, as it might not /
我计划运行regex is javascript。您可以使用
\/
来转义要在正则表达式中使用的斜杠:
因此,结果将是:
var input = "http://example.com/...../post/index/88/mike-hey-dddd";
var match = input.match(/\/index\/(\d+)/i);
// Make sure to validate the result, as it might not
// match for a given alternative url.
var number = match ? match[1] : false;
alert(number);
你试过什么正则表达式?它总是在同一个位置吗?也许://\/index\//(\d+)\//g