Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

JavaScript RegExp to Find Alternative Text



To match any of the specified alternatives, follow the below-given pattern −

(foo|bar|baz)

Example

You can try to run the following code to find any alternative text −

<html>
   <head>
      <title>JavaScript Regular Expression</title>
   </head>
   <body>
      <script>
         var myStr = "one,one,one, two, three, four, four";
         var reg = /(one|two|three)/g;
         var match = myStr.match(reg);

         document.write(match);
      </script>
   </body>
</html>
Updated on: 2020-06-23T07:32:05+05:30

202 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements