Javascript examples for RegExp:Bracket
The [abc] expression matches any character between the brackets.
For example,
[^abc] expression matches any character NOT between the brackets.
The following code shows how to Do a global search for the character "h" in a string:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w . jav a 2 s .c o m var str = "this is a test abc 123 asdf123 321ewads"; var patt1 = /[a-s]/gi; var result = str.match(patt1); document.getElementById("demo").innerHTML = result; } </script> </body> </html>