Created
February 21, 2017 05:31
-
-
Save beepony/268001426e683170e68890cbc01b84ed to your computer and use it in GitHub Desktop.
ruby regx
This file contains 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
#!/usr/bin/env ruby | |
string = "RyanOnRails: This is a test" | |
one, two, three = string.match(/(^.*)(:)(.*)/i).captures | |
p one #=> "RyanOnRails" | |
p two #=> ":" | |
p three #=> " This is a test" | |
# better one | |
if match = string.match(/(^.*)(:)(.*)/i) | |
one, two, three = match.captures | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment