I want to slip a text by spaces and special character but I want to keep those character. The text I want to separate is in the CSS format. Take the following example:
.box {
background: red;
color: white;
}
I already have that in an array format by line like this
[ " .box { " ]
[ " background: red; " ]
[ " } " ]
[ " color: white; " ]
And I want to split every string by space and these characters ':' and ';'
so I'll en up with something like this:
[".box"] ["{"]
["background"] [":"] ["red"] [";"]
["color"] [":"] ["white"] [";"]
["}"]
I want to take in mind the syntax, here are some possible scenarios:
background: red; -> ["background"] [":"] ["red"] [";"]
background : red ; -> ["background"] [":"] ["red"] [";"]
backg round : red ; -> ["backg"] ["round"] [":"] ["red"] [";"]
Thanks in advance!
EDIT
About the duplicate question, I'm looking into the other post answer and it might help in my specific case, nevertheless the problem discussed might be in different other context other than parsing CSS. Please consider that, and thank you for the reference.