我想在JavaScript中的两个字符之间搜索字符串,jQuery。如何在jQuery中的两个字符之间搜索字符串
这里ID我的网址
http://local.evibe-dash.in/vendors/new?status=Phone&count=60&type= “艺术家,魔术”。
我想在"status=" and first &
之间搜索字符串,这样当我得到比这个更大的值时,我可以放入URL。
我想在JavaScript中的两个字符之间搜索字符串,jQuery。如何在jQuery中的两个字符之间搜索字符串
这里ID我的网址
http://local.evibe-dash.in/vendors/new?status=Phone&count=60&type= “艺术家,魔术”。
我想在"status=" and first &
之间搜索字符串,这样当我得到比这个更大的值时,我可以放入URL。
使用match()
与捕获组正则表达式
var str = 'http://local.evibe-dash.in/vendors/new?status=Phone&count=60&type="artist,magic".';
var res = str.match(/status=([^&]+)/)[1]
document.write(res);
,或者使用split()
var str = 'http://local.evibe-dash.in/vendors/new?status=Phone&count=60&type="artist,magic".';
var res = str.split('status=')[1].split('&')[0];
document.write(res);
var str = 'http://local.evibe-dash.in/vendors/new?status=Phone&count=60&type="artist,magic".',
ind = str.indexOf('status=');
var res = str.substring(ind + 7, str.indexOf('&', ind));
document.write(res);
谢谢。你解决了我动态刷新网址的问题。 – Vikash
@Vikash很高兴帮助! –
是你想怎么办得到的参数? –
雅,实际上我想把状态的值,如果它从下拉列表中选择后更改 – Vikash
'var str ='http://local.evibe-dash.in/vendors/new?status = Phone&count = 60&type = “艺术家,魔术'”。 str.substring(str.indexOf('status =')+ 7,str.indexOf('&'))' –