Skip to content

Instantly share code, notes, and snippets.

@campanalbero
Created April 2, 2015 03:29
Show Gist options
  • Save campanalbero/f2dd83dc133447ab1b65 to your computer and use it in GitHub Desktop.
Save campanalbero/f2dd83dc133447ab1b65 to your computer and use it in GitHub Desktop.
regexp-sample
var uri = "http://localhost:8080/reinput?key=1234-5678-90ab-cdef";
var reg = /\\??key=[0-9a-f\\-]+/;
if (uri.match(reg)) {
console.log("matched");
var replaced = uri.replace(reg, "key=hoge");
console.log(replaced);
} else {
console.log("unmatched");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment