Advertisement
Guest User

Untitled

a guest
Apr 28th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. RegEx's that you can use to match @media rules are:
  2.  
  3. ^\@media\s(.*?)\{$
  4.  
  5. ^ = assert position at start of the string
  6. \@ = matches the character @ literally
  7. media = matches the characters media literally
  8. \s = match any white space character [\r\n\t\f ]
  9. .*? = matches any character (except newline)
  10. { = matches the character { literally
  11. $ = assert position at end of the string
  12. \@media\s(.*?)\{
  13.  
  14. \@ = matches the character @ literally
  15. media = matches the characters media literally
  16. \s = match any white space character [\r\n\t\f ]
  17. .*? = matches any character (except newline)
  18. { = matches the character { literally
  19. Also you can use the i to make the RegEx's case insensitive (i only ignores the case of [a-zA-Z])
  20.  
  21. Here are four possible ways of detecting @media rules using RegEx:
  22.  
  23. /^\@media\s(.*?)\{$/
  24. /^\@media\s(.*?)\{$/i
  25. /\@media\s(.*?)\{/
  26. /\@media\s(.*?)\{/i
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement