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

前端 未结 4 1815
生来不讨喜
生来不讨喜 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条回答
  •  心在旅途
    2020-12-29 20:03

    "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(" ")
    

提交回复
热议问题