Created
May 26, 2014 08:37
-
-
Save kanakiyajay/5ee6776b8015770744ab to your computer and use it in GitHub Desktop.
Get only one value from the query string value using Regex and javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getQueryMatch (query,key) { | |
var regx = new RegExp(key+"=([^&]*)"); | |
return decodeURIComponent(query.match(regx)[1]); | |
} | |
console.log(getQueryMatch("http://example.com?x=hello&y=des%20t","y")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment