Menu

gitpiper

splitLines javascript Code Snippet in 2024

stringregexpbeginner

Last Updated: 16 May 2024

Splits a multiline string into an array of lines.

  • Use String.prototype.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.' , '']

javascript snippet similar to splitLines For You in May 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️