header
padding 12px 0px
background #eee
border-bottom 1px solid #ccc
linearGradient(#f8f8f8, #e6e6e6)
nav
font-size 15px
width 400px
position absolute
max-height 40px
right 0px
bottom 5px
text-align right
nav .portrait
position relative
top 9px
margin-right 5px
left 0px
img
border 1px solid #ccc
width 30px
height 30px
transition border-color 0.25s
&:hover
border-color #676767[/code]
I am trying to match the selector groups (header, nav, nav .portrait, img, &:hover) but not match any of the other lines. I am aware I could match every line and then process submatches on that to determine if it is in fact a valid selector group, but if possible I would like to avoid that and just match the selector groups in one swoop.
I am pretty good at regex and I got it working perfectly on [rubular.com/r/oF8b6TzArG](http://rubular.com/r/oF8b6TzArG), but when I try to do it in a tmLanguage file it does not seem to work at all. Perhaps it is some limitation with backreferences that could be a variable number of spaces?
Here is what I am working with
[code]<dict>
<key>match</key>
<string>^( *?)(&amp;\:\.\#a-zA-Z](.*?))(?=\n\1 +)</string>
<key>captures</key>
<dict>
<key>2</key>
<dict>
<key>name</key>
<string>meta.selector.stylus</string>
</dict>
</dict>
</dict>

I am also aware if we assume one selector per line without spaces I could change it to ^( ?)(&\:.#a-zA-Z](\S?))(?=\n) and that will work in Sublime.

Any help would be greatly appreciated.

Also don't worry about the whole tabs vs. spaces thing. After I get it working I can easily adapt it to work with both.

Yes, and the pattern I am using is trying to match just a single line. Matching against a single line still lets you do a positive look ahead onto the next line. I don't think the problem has to do with single line vs. multi line because it still fails when using the begin and end tags.

It seems to me that the problem is that the backreference fails to match a variable number of spaces correctly to detect indentation.