Skip to content

Instantly share code, notes, and snippets.

@johnsinco
Created October 2, 2013 19:25
Show Gist options
  • Save johnsinco/6799177 to your computer and use it in GitHub Desktop.
Save johnsinco/6799177 to your computer and use it in GitHub Desktop.
ruby double-regex-error
# do something cool with input using a case
input = "some fool string"
case input
when /foo/
# do something
when /bar/
# do something else
when /(fool)/
# now do something special using the capture
local_var = $1 # get the capture
p "local capture is #{$1}"
local_var.gsub(/o/,'a')
p "local capture is #{$1}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment