Javascript examples for RegExp:Bracket
The (x|y) expression matches any of the alternatives specified.
The following code shows how to Do a global search to find any of the specified alternatives (red|green):
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from ww w . j av a 2 s . com var str = "01234567890123456789"; var patt1 = /(0|5|7)/g; var result = str.match(patt1); document.getElementById("demo").innerHTML = result; } </script> </body> </html>