So I have a string representing DIV innerHTML and I want to extract all styles from spans to an array. Here are example strings:
string1 = <span style="background-color: #808080">U posljednji čas. 123</span>
string2 = <span style="background-color: #808080">U <span style="font-style: italic">posljednji</span> čas. 123</span>
And I want the output to look something like this:
string1output1 = ['background-color: #808080']
string1output2 = ['background-color: #808080', 'font-style: italic']
Or:
string2output1 = ['<span style="background-color: #808080">']
string2output2 = ['<span style="background-color: #808080">', '<span style="font-style: italic">']
What would be the easiest and most effective way to do this, having in mind that there may be more than 1 span with styling inside string? Also I would need to replace the span with something, so second method would be easier for that because I could just call replace on string with items from array.
Thanks for your help