Regular Expressions 101

Community Patterns

Find CSS Class with ability to replace

0

Regular Expression
ECMAScript (JavaScript)

/
(class=(\\?(?:"|'){1,2})(?:[-a-z0-9 ]* )?)success(?=\2|\s)
/
gi

Description

Changing class names is hard with a large codebase written in multiple languages. Classes can appear in several constructs. This tries to match the various ways a class can be represented in HTML.

Plug the RegEx in to Sublime Text 2 using "Find in Files...". When replacing in ST2, change $1 to \1.

Submitted by Matthew (@sirlancelot) - 9 years ago