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); 

fiddle demo

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

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -