JavaScript RegExp \S Metacharacter Last Updated : 28 Nov, 2024 Comments Improve Suggest changes Like Article Like Report The RegExp \S Metacharacter in JavaScript is used to find the non-whitespace characters. The whitespace character can be a space/tab/new line/vertical character. It is the same as [^\t\n\r]. JavaScript let str = "Geeky@128"; let regex = new RegExp("\\S", "g"); let match = str.match(regex); console.log(match); Output[ 'G', 'e', 'e', 'k', 'y', '@', '1', '2', '8' ] Syntax/\S/ // ornew RegExp("\\S")Syntax with modifiers/\S/g // ornew RegExp("\\S", "g")Example 1: Matches the non-whitespace characters. JavaScript let str = "GeeksforGeeks @ _123_ $"; let regex = /\S/g; let match = str.match(regex); console.log(match); Output[ 'G', 'e', 'e', 'k', 's', 'f', 'o', 'r', 'G', 'e', 'e', 'k', 's', '@', '_', '1', '2', '3', '_', '$' ] Example 2: Matches the non-whitespace strings. JavaScript const regex = /\S+/g; const str = "Hello World! This is JavaScript"; const matches = str.match(regex); console.log(matches); Output[ 'Hello', 'World!', 'This', 'is', 'JavaScript' ] Supported BrowsersChromeSafariFirefoxOperaEdgeWe have a complete list of Javascript RegExp expressions, to check those please go through this JavaScript RegExp Complete Reference article.We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript. Comment More infoAdvertise with us Next Article JavaScript RegExp s Metacharacter V Vishal Chaudhary 2 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-RegExp Similar Reads JavaScript RegExp S Metacharacter The RegExp \S Metacharacter in JavaScript is used to find the non-whitespace characters. The whitespace character can be a space/tab/new line/vertical character. It is the same as [^\t\n\r].JavaScriptlet str = "Geeky@128"; let regex = new RegExp("\\S", "g"); let match = str.match(regex); console.log 1 min read JavaScript RegExp s Metacharacter The \s metacharacter in JavaScript regular expressions matches any whitespace character. This includes spaces, tabs, form feeds, line breaks, and other whitespace characters as defined in Unicode.JavaScriptlet regex = /\s/; let str1 = "Hello World"; let str2 = "HelloWorld"; console.log(regex.test(st 2 min read JavaScript RegExp Metacharacter The \b metacharacter in JavaScript regular expressions represents a word boundary, allowing you to match positions where a word begins or ends. A word boundary is the position between a word character (\w: letters, digits, or underscores) and a non-word character (\W: everything else, including spac 2 min read JavaScript RegExp Metacharacter The \r metacharacter in JavaScript regular expressions matches a carriage return character. A carriage return is a special control character (\r) with the ASCII code 13, often used to represent the end of a line in text files created on older operating systems (e.g., Windows uses \r\n for line break 2 min read JavaScript RegExp w Metacharacter The \w metacharacter in JavaScript regular expressions matches any word character. A word character is defined as:Any alphanumeric character (letters a-z, A-Z, numbers 0-9)The underscore character (_)It does not match spaces, punctuation, or other non-alphanumeric characters.JavaScriptlet regex = /\ 2 min read JavaScript RegExp Like