How to split string into only two parts with a given character in Ruby?

前端 未结 4 1809
生来不讨喜
生来不讨喜 2020-12-29 19:42

Our application is mining names from people using Twitter to login.

Twitter is providing full names in a single string.

Examples

1. \"Froeder         


        
4条回答
  •  -上瘾入骨i
    2020-12-29 19:57

    String#split takes a second argument, the limit.

    str.split(' ', 2)
    

    should do the trick.

提交回复
热议问题