Last active
December 14, 2015 11:28
-
-
Save theotherzach/5079453 to your computer and use it in GitHub Desktop.
Find the first name
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
names = ['Last, First M', 'Last,First!@#$'] | |
def word_after_comma | |
/(?<=[,])(\s?)(\w*)/ | |
end | |
first_names = names.map { |x| x.slice(word_after_comma).strip } | |
#=> ["First", "First"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/cretan/07fcb2fc895752bea4bf