visionmedia/node-css-parse — pull request #8 by rstacruz (2012-09-01 18:31:24+00:00)
Title: Support quotes in selectors

Handles cases such as `abbr[title*="{"] { ... }`.

Okay, this is a complicated/controversial one.

By the way, I opted for a `for` loop here (instead of `Array.prototype.map`) because this means css-parse can still work on an older browser.

...that, and also, I can't find a way to make the regex consume the whitespaces.

For the curious: `((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|[^{])+)` broken down is:

* `'(?:\\'|.)*?'` - looks for a single-quoted string, consuming the escaped ones along the way
* `"(?:\\"|.)*?"` - consumes a double-quoted string in the same fashion

And (`'...'`|`"..."`|`[^,]`)+ is pretty much how it works -- it looks for a single-quoted string, a double-quoted string, or something that's not a `{`, in that order.