Applying this regex pattern:
/(?:(^| |\>|\+))+([a-z\-\_]+)/gi
to this string:
body.test ol+li ol > li #foobar p>span a[href=*]
I get these matches, comma separated:
body, ol,+li, ol, > li, p,>span, a
Why do some matches have the leading space , > and + sign? I'd expect this part of my regex (?:(^| |\>|\+)) to match those signs, but not capture them.
Edit: I am trying to match html tags and css selectors contributing to css specificity of an css selector. Thus I want to match each li or span or so forth on its own, without the + or >.