Sign inorRegister Site is for SALE!

In general, as any beginning programmer of JavaScript (2 years ago), I wanted to carry out everything myself. So there appeared a very fast regular expression of 280 characters.

A little history


Approximately one and a half years ago, I found out about the library “yass”, which has been the fastest tool to find DOM elements in a JavaScript through CSS selectors (reference to tests).
Then I had a terrible interest. I wanted to invent a way that will be even faster. At that time, I just was reading the book “Regular expressions- Library of programmer” the second edition of J. Fridley. It was summer, I was still a student and I had plenty of free time. Work has begun...

I decided to write an article because of the following expression, which can almost completely analyze the CSS selector query (even a little advanced, which goes beyond the standard CSS3):
/(?:(?:\s*[+>~,]\s*|\s+)|[^:+>~,\s\\[\]]+(?:\\.[^:+>~,\s\\[\]]*)*)|\[(?:[^\\[\]]*(?:\\.[^\\[\]]*)*|[^=]+=~?\s*(?:"[^\\"]*(?:\\.[^"\\]*)*"|'[^\\']*(?:\\.[^'\\]*)*'))\]|:[^\\:([]+(?:\\.[^\\:([]*)*(?:\((?:[^\\()]*(?:\\.[^\\()]*)*|"[^\\"]*(?:\\.[^"\\]*)*"|'[^\\']*(?:\\.[^'\\]*)*')\))?/g
0
Pirat 5 september 2011, 14:53