Regular Expressions 101

Community Patterns

Match all Tailwind CSS classes prefixed with dark:

1

Regular Expression
PCRE2 (PHP >=7.3)

/
\b\sdark:[\w\-:]*\b
/
gm

Description

A simple expression for removing Tailwind CSS classes that are prefixed with dark: from your HTML. Can be easily changed to remove any other classes with a specific prefix. I made this so I could easily remove dark mode from Tailwind CSS components I find online.

Submitted by hexrw - 8 months ago