Skip to content

Instantly share code, notes, and snippets.

@vladimir-e
Last active August 29, 2015 14:02
Show Gist options
  • Save vladimir-e/77c13df1379b5ceeb984 to your computer and use it in GitHub Desktop.
Save vladimir-e/77c13df1379b5ceeb984 to your computer and use it in GitHub Desktop.
capture regex pattern with ruby gsub
str = "number 5"
str.gsub(/number\ (\d+)/, '#\1')
# => "#5"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment