javascript - Match and remove everything up to and including "=" in string with regex -
given url: http://localhost:3000/test/tagger.html?id=31415
need strip , including =
sign, , set value on right of equal sign textbox field. have following matches equal sign, keeps it. how can remove it?
var url = "http://localhost:3000/test/tagger.html?id=31415"; var regex = /=.*/; // match '=' , capture follows var accountid = url.match(regex); $(".accountnumber").val(accountid);
you can use
var accountid = url.substr(url.indexof("=") + 1); //returns after `=`
edit:
to check if =
exists in url can put if
this:
if(url.indexof("=") != -1){ var accountid = url.substr(url.indexof("=") + 1); //returns after `=` }
Comments
Post a Comment