Our application is mining names from people using Twitter to login.
Twitter is providing full names in a single string.
Examples
1. \"Froeder
String#split takes a second argument, the limit.
str.split(' ', 2)
should do the trick.
The second argument of .split()
specifies how many splits to do:
'one two three four five'.split(' ', 2)
And the output:
>> ruby -e "print 'one two three four five'.split(' ', 2)"
>> ["one", "two three four five"]
Alternative:
first= s.match(" ").pre_match
rest = s.match(" ").post_match
"Ludwig Van Beethoven".split(' ', 2)
The second parameter limits the number you want to split it into.
You can also do:
"Ludwig Van Beethoven".partition(" ")