How can this line be split while preserving quoted strings
>div#a.more.style.ui[url="in.tray"]{value}
where the chars for the split are
>
#
.
[
{
to yield:
>div
#a
.more
.style
.ui
[url="in.tray"]
{value}
Current effort is:
\>|\[|\{|#|\.?(?:(["'])(?:\\?.)*?\1)*
with "in.tray"
being split on.
Update 1:
The solution needs to be regex based as the pattern is assembled from the keys of a JS object in the existing code, which are:
JSObject
'>': function ...
'^': function ...
'[': function ...
...
with the functions used as callbacks to process the output from the regex.
The target string is an Emmet macro and may contain plain characters to start, as well as possible repeats of at least ^
, $
to be treated as separate elements e.g:
p>div>div>span^h2^^h1>div#a.li^mo+re.st*yle.ui[url="in.tray"]{value}$$$
Current effort based on @tim-pietzcker using .match()
but with an empty last match filtered out:
[a-z$^+*>#.[{]{0,1}(?:"[^"]*"|[^"$^+*>#.[{]){0,}