Created
May 30, 2014 16:56
-
-
Save michaelminter/64f072de90b9af0b61fb to your computer and use it in GitHub Desktop.
String extraction with RegEx -- replaces match
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
str = "GB is not Great Britain" | |
matches = str.match /(Great.*)/ | |
matches[1] | |
# => "Great Britain" | |
str[/(Great.*)/, 1] | |
# => "Great Britain" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment