-4
I have these background attributes of an element:
"background: rgba(0, 0, 0, 0) linear-gradient(0.25turn, rgb(117, 117, 117), rgb(46, 184, 46), rgb(21, 21, 21), rgb(166, 166, 166)) repeat scroll 0% 0%;"
How can I take the 4 different colors of the gradient and separate them into an array like this:
[117,117,117],[46,184,46],[21,21,21],[45,175,230],[166,166,166],
I think the way I’m trying is wrong: (I left well divided to understand better)
var colorsP = "background: rgba(0, 0, 0, 0) linear-gradient(0.25turn, rgb(117, 117, 117), rgb(46, 184, 46), rgb(21, 21, 21), rgb(166, 166, 166)) repeat scroll 0% 0%;"
colorsP = colorsP.split('0.25turn, ');
colorsP = colorsP[1];
colorsP = colorsP.split(') ');
colorsP = colorsP[0];
colorsP = colorsP.split('rgb');
colorsP = colorsP.filter((value)=>value!='');
console.log(colorsP);
Thanks Marcos, you killed him. I need to learn more about regular expressions because I couldn’t understand anything about how you identified the characters. Can you tell me why the question was so negative? It’s a bad question? Was it the way I wrote it ? Or my solution was so far away that I really deserved it ?
– marcelo
Dispose, we’re here to help. About the ER, at first it’s kind of scary really, but a little training and reading, quickly you get the hang of it. I suggest you use https://regexr.com/ to play with it. There’s a bit of explanation and you can see right away how the ER works. About the negativity of the question, it is very subjective, each vote comes from a person and each one with a point of view. In any case, read the website helps, especially the part of the questions that offer great tips.
– Marcos Alexandre
Thanks Marcão, I’ll take a look! I edited the question, I think it looks better. Hug.
– marcelo