Search an array by converting array to string and use regex - Javascript Array Operation

Javascript examples for Array Operation:Array Convert

Description

Search an array by converting array to string and use regex

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from   w ww. ja  v a2s . co  m*/
var test = [['code', 'name'], ['code', 'name'], ['code', 'name3'], ['code', 'name4'], ['code', 'name']];
var value = "name4";
if( test.join(",").match(new RegExp(value, "gi")) !== null ) {
    console.log("Found a match");
}
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials