Menu

gitpiper

containsWhitespace javascript Code Snippet in 2024

stringregexpbeginner

Last Updated: 9 April 2024

Checks if the given string contains any whitespace characters.

  • Use RegExp.prototype.test() with an appropriate regular expression to check if the given string contains any whitespace characters.
const containsWhitespace = str => /\s/.test(str);
containsWhitespace('lorem'); // false containsWhitespace('lorem ipsum'); // true

javascript snippet similar to containsWhitespace For You in April 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! ✌️