Skip to content

Instantly share code, notes, and snippets.

@adikahorvath
Last active August 29, 2015 14:17
Show Gist options
  • Save adikahorvath/0ad9e4e13adff53f4ff1 to your computer and use it in GitHub Desktop.
Save adikahorvath/0ad9e4e13adff53f4ff1 to your computer and use it in GitHub Desktop.
regex CSS
/* if contains "post" */
div[class*="post"] {
color: red;
}
/* if begins with "post" */
div[class^="post"] {
color: red;
}
/* if ends with "post" */
div[class$="post"] {
color: red;
}
/* if space separated "post" */
div[class~="post"] {
color: red;
}
/* if dashed "post" */
div[class|="post"] {
color: red;
}
<!-- if contains "post" -->
<div class="post-45"></div>
<div class="last-post"></div>
<div class="last-post-with-picture"></div>
<!-- if begins with "post" -->
<div class="post-45 col-3"></div>
<!-- if ends with "post" -->
<div class="col-3 with-picture 45-post"></div>
<!-- if space separated "post" -->
<div class="col-3 post with-picture"></div>
<!-- if dashed "post" -->
<div class="last-post-with-picture"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment