Skip to content

Instantly share code, notes, and snippets.

@maxivak
Created October 1, 2013 12:52
Show Gist options
  • Save maxivak/6777978 to your computer and use it in GitHub Desktop.
Save maxivak/6777978 to your computer and use it in GitHub Desktop.
Ruby Regex Examples
# find all occurrences of $name in the string
formula = "$paramname > $value && $x>0"
s = formula.gsub(/\$([a-z_\d]+)/) do
name = $1
if name=='now'
v = Time.now.utc.now
else
v = ..
end
#
v
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment