Skip to content

Files

Latest commit

7a7c31b · Jan 10, 2018

History

History
13 lines (9 loc) · 320 Bytes

splitLines.md

File metadata and controls

13 lines (9 loc) · 320 Bytes

splitLines

Splits a multiline string into an array of lines.

Use String.split() and a regular expression to match line breaks and create an array.

const splitLines = str => str.split(/\r?\n/);
splitLines('This\nis a\nmultiline\nstring.\n'); // ['This', 'is a', 'multiline', 'string.' , '']