Created
August 19, 2015 17:21
-
-
Save craigweston/7d26055d5cec0e84a91c to your computer and use it in GitHub Desktop.
One liner that converts array of names from "Smith, Joe" format to "Joe Smith"
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 = ['Mike Smith', 'McDonald, John', 'Jill Doe'] | |
names.map { |e| e.split(/,\s*/).reverse!.join(' ') } | |
# => ["Mike Smith", "John McDonald", "Jill Doe"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment