Merge pull request #384 from Chalarangelo/split-lines
[FEATURE] Add splitLines
This commit is contained in:
13
snippets/splitLines.md
Normal file
13
snippets/splitLines.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
### 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.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const splitLines = str => str.split(/\r?\n/);
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
splitLines('This\nis a\nmultiline\nstring.\n'); // ['This', 'is a', 'multiline', 'string' , '']
|
||||||
|
```
|
||||||
@ -118,6 +118,7 @@ similarity:array
|
|||||||
sleep:function
|
sleep:function
|
||||||
sortCharactersInString:string
|
sortCharactersInString:string
|
||||||
speechSynthesis:media
|
speechSynthesis:media
|
||||||
|
splitLines:string
|
||||||
spreadOver:adapter
|
spreadOver:adapter
|
||||||
standardDeviation:math
|
standardDeviation:math
|
||||||
sum:math
|
sum:math
|
||||||
|
|||||||
Reference in New Issue
Block a user