Skip to content

Instantly share code, notes, and snippets.

@ashaw
Created October 9, 2010 17:13
Show Gist options
  • Save ashaw/618388 to your computer and use it in GitHub Desktop.
Save ashaw/618388 to your computer and use it in GitHub Desktop.
irb(main):094:0> param_re = /[?&]([\w]+)=?([\w]+)?/
=> /[?&]([\w]+)=?([\w]+)?/
irb(main):095:0> "http://google.com?foo=bar&baz=bag&woz=wag".scan(param_re)
=> [["foo", "bar"], ["baz", "bag"], ["woz", "wag"]]
irb(main):096:0> "http://f.g?b".scan(param_re)
=> [["b", nil]]
irb(main):097:0> "http://z.com?f&g=foo".scan(param_re)
=> [["f", nil], ["g", "foo"]]
irb(main):098:0> "http://z.com?352=deg&w22=33".scan(param_re)
=> [["352", "deg"], ["w22", "33"]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment