Capture multiple RGB values with regex match - Javascript RegExp

Javascript examples for RegExp:RegExp Match

Description

Capture multiple RGB values with regex match

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.  j ava2 s .  c  om
var input = " background: linear-gradient(to right,  rgba(255,0,0,1) 0%, rgba(0,0,255,1) 100%);";
var array = input.match(/rgba\([^\)]*\)/gi);
for (var i=0; i<array.length; i++)
    console.log(array[i].match(/\((.*)\)/)[1]);
    }

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

Related Tutorials