Created
April 28, 2016 18:26
-
-
Save bhowe/db9190be35a26ca1719684200e1b9f71 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| RegEx's that you can use to match @media rules are: | |
| ^\@media\s(.*?)\{$ | |
| ^ = assert position at start of the string | |
| \@ = matches the character @ literally | |
| media = matches the characters media literally | |
| \s = match any white space character [\r\n\t\f ] | |
| .*? = matches any character (except newline) | |
| { = matches the character { literally | |
| $ = assert position at end of the string | |
| \@media\s(.*?)\{ | |
| \@ = matches the character @ literally | |
| media = matches the characters media literally | |
| \s = match any white space character [\r\n\t\f ] | |
| .*? = matches any character (except newline) | |
| { = matches the character { literally | |
| Also you can use the i to make the RegEx's case insensitive (i only ignores the case of [a-zA-Z]) | |
| Here are four possible ways of detecting @media rules using RegEx: | |
| /^\@media\s(.*?)\{$/ | |
| /^\@media\s(.*?)\{$/i | |
| /\@media\s(.*?)\{/ | |
| /\@media\s(.*?)\{/i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment