Javascript examples for RegExp:Metacharacter
The \S metacharacter matches a non-whitespace character.
A whitespace character can be:
The following code shows how to Do a global search for non-whitespace characters in a string:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w. ja v a 2 s .c o m var str = "this is a test ?"; var patt1 = /\S/g; var result = str.match(patt1); document.getElementById("demo").innerHTML = result; } </script> </body> </html>