Skip to content

Instantly share code, notes, and snippets.

@theotherzach
Last active December 14, 2015 11:28
Show Gist options
  • Save theotherzach/5079453 to your computer and use it in GitHub Desktop.
Save theotherzach/5079453 to your computer and use it in GitHub Desktop.
Find the first name
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"]
@bryanschoeff
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment