Files
30-seconds-of-code/snippets/removeWhitespace.md
2022-06-08 09:34:23 +03:00

529 B

title, tags, expertise, cover, firstSeen, lastUpdated
title tags expertise cover firstSeen lastUpdated
Remove whitespaces string,regexp beginner blog_images/tropical-bike.jpg 2020-10-13T09:37:17+03:00 2020-11-03T21:46:13+02:00

Returns a string with whitespaces removed.

  • Use String.prototype.replace() with a regular expression to replace all occurrences of whitespace characters with an empty string.
const removeWhitespace = str => str.replace(/\s+/g, '');
removeWhitespace('Lorem ipsum.\n Dolor sit amet. ');
// 'Loremipsum.Dolorsitamet.'