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/)
What I'd like to do is split on either \r\n
or just \n
.
So how what would the regex be to split on either of those?
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/)
What I'd like to do is split on either \r\n
or just \n
.
So how what would the regex be to split on either of those?
To be safe for operating systems. I would do /\r?\n|\r\n?/
Perhaps do a split on only '\n' and remove the '\r' if it exists?