Regex for capturing variables in curved brackets - Javascript RegExp

Javascript examples for RegExp:Bracket

Description

Regex for capturing variables in curved brackets

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(){/* www .j  ava  2  s  .  c  om*/
var str = "heres:a:func('var1', 'var2', 'var3', 2)"
var args = /\(\s*([^)]+?)\s*\)/.exec(str);
if (args[1]) {
  args = args[1].split(/\s*,\s*/);
}
console.log(args);
    }

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

Related Tutorials