Regular Expressions 101

Community Patterns

Community Library Entry

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 - a year ago