Shpigford Shpigford - 1 year ago 93
Ruby Question

Split on different newlines

Right now I'm doing a

on a string and assuming that the newline from the user is
like so:


What I'd like to do is split on either
or just

So how what would the regex be to split on either of those?

Answer Source

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

Example usage:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download