Created
June 3, 2009 19:20
-
-
Save jcsalterego/123186 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # | |
| # How do I extract a parameter from a URL in plain Ruby? | |
| # "http://foo.com/bar.html?a=sdfas&b=xyz Want the value of parameter a. | |
| # - http://twitter.com/mperham/status/2019870182 | |
| # | |
| URL = "http://foo.com/bar.html?a=sdfas&b=xyz" | |
| paramify = lambda url: dict([kv.split("=") | |
| for kv | |
| in url.split("?")[1].split("&")]) | |
| print paramify(URL)['a'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment