Created
July 28, 2014 11:17
-
-
Save kontur/9fcbaef1b7396927d569 to your computer and use it in GitHub Desktop.
Javascript regexp to extract matrix values from a String into an Array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// via http://stackoverflow.com/a/14397066/999162 | |
var matrixToArray = function(str){ | |
return str.match(/(-?[0-9\.]+)/g); | |
}; | |
matrixToArray('rgba(0, 0, 0, 0.5)'); // => ['0', '0', '0', '0.5'] | |
matrixToArray('matrix(1, 0, 0, 1, -770, 0)'); // => ['1', '0', '0', '1', '-770', '0'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment