Split on different newlines

前端 未结 8 1086
自闭症患者
自闭症患者 2021-02-01 12:57

Right now I\'m doing a split on a string and assuming that the newline from the user is \\r\\n like so:

string.split(/\\r\\n/)
<         


        
8条回答
  •  独厮守ぢ
    2021-02-01 13:14

    Did you try /\r?\n/ ? The ? makes the \r optional.

    Example usage: http://rubular.com/r/1ZuihD0YfF

提交回复
热议问题