I am trying to replace alla the occurences of the string translate3d(-640px, 0px, 0px); with translate(-640px).
This is what I am doing:
var string = "width: 960px; height: 548px; transition: 0s; -webkit-transition: 0s; transform: translate3d(-640px, 0px, 0px); -webkit-transform: translate3d(-640px, 0px, 0px);";
var regExp = //; //I am not able to create this one
var matches = regExp.exec(string);
var left = matches[1]; //this will give the value -640px
var newstring = string.replace('translate3d('+left+', 0px, 0px)', 'translate('+left+')');
There are 2 problems:
Thanks for any help!
You can use:
var newstring = string.replace(/translate3d\(([^,]+)[^)]*\)/g, 'translate($1)');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With