I've appended a value to my url, so it looks like this now:
www.somepage.com&myValue=xxxxx
I get my url as follows:
var url = document.URL;
What I want now is everything after myValue=
.
What regex would I use to acheive this?
Quick and dirty:
//split the url at the "&"
split_back=(url.split("&"));
//now split the url at the "="
split_value=(split_back[1].split("="));
The value you need is in split_value[1]. check this jsfiddle : http://jsfiddle.net/55rmkx76/2/
You could do like this,
> var s = 'www.somepage.com&myValue=xxxxx';
undefined
> var re = /myValue=(.*)/;
undefined
> console.log(re.exec(s)[1])
xxxxx
undefined
> var s = 'www.somepage.com&myValue=xxxxx';
undefined
> s.split('myValue=')[1]
'xxxxx'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.