Created
August 14, 2011 16:59
-
-
Save hekt/1145069 to your computer and use it in GitHub Desktop.
RegEx for parsing CSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(# comment ) | |
(/\*(?:(?!\*/)[\s\S])*\*/) | |
(/\*(?:[^*]|\*[^/])*\*/) | |
(# @keyframes-rule ) | |
(@(?:-webkit-|-moz-)?keyframes(?:[\s\n]|/\*(?:(?!\*/)[\s\S])*\*/)+[a-zA-Z0-9_\-]+(?:[\s\n]|/\*(?:(?!\*/)[\s\S])*\*/)*{(?:[\s\n]|/\*(?:(?!\*/)[\s\S])*\*/)*(?:(?:from|to|[0-9]{1,3}%)(?:[\s\n]|/\*(?:(?!\*/)[\s\S])*\*/)*{(?:[^{}"']|/\*(?:(?!\*/)[\s\S])*\*/|'[^']*'|"[^"]*")*}(?:[\s\n]|/\*(?:(?!\*/)[\s\S])*\*/)*)+(?:[\s\n]|/\*(?:(?!\*/)[\s\S])*\*/)*}) | |
(# ruleset ) | |
((?:[^{}"']|'[^']*'|"[^"]*")+(?:[\s\n]|/\*(?:(?!\*/)[\s\S])*\*/)*{(?:[^{}"']|/\*(?:(?!\*/)[\s\S])*\*/|'[^']*'|"[^"]*")*}) | |
(# block ) | |
({(?:[^{}"']|/\*(?:(?!\*/)[\s\S])*\*/|'[^']*'|"[^"]*")*}) | |
(# declaration ) | |
([a-zA-Z\-]+(?:\s|/\*(?:(?!\*/)[\s\S])*\*/)*:(?:\s|/\*(?:(?!\*/)[\s\S])*\*/)*(?:"[^"]*"|'[^']'|[^:;{}])+;?) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment