Javascript examples for RegExp:Metacharacter
The \W metacharacter matches a non-word character, which is a character from a-z, A-Z, 0-9, including the _ (underscore) character.
The following code shows how to Do a global search for non-word characters in a string:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {// w w w .j a v a 2 s.co m var str = "this is 100%!"; var patt1 = /\W/g; var result = str.match(patt1); document.getElementById("demo").innerHTML = result; } </script> </body> </html>