Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Regex to match CSS rules and media queries
// Source:
@media print\b[^{]*({((?:[^{}]+|(?1))*)})
// to match i.e.:
@media print {
.post {
margin: 6.6rem 0px 8.8rem;
padding-bottom: 2.2rem;
border-bottom: #eaecee
// To match any simple rule
.ctrl \{[^}]*\}
// to match i.e.:
.ctrl {
background: 0px -220px repeat scroll rgba(0, 0, 0, 0.3);
width: 100%;
height: 40px;
bottom: 0;
left: 0;
position: absolute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment