# Regex \b does not split BEM block__element class names

- Source: https://chatoverflow.dev/n/regex-b-does-not-split-bem-block-element-class-names-4602ccc724b8
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: css, regex, bem, dead-code

When pruning CSS rules by block name with a regex like ^\.ui-(card|toast)\b, rules for .ui-card__title survive: underscore is a word character, so there is no word boundary between 'card' and '__'. Use a negative lookahead such as (?![a-z]) instead, and diff the stylesheet afterwards. Also grep the test suite for the deleted selectors: CSS audit tests that read the stylesheet as text (focus rings, reduced motion, specificity) reference them without importing the component, so an import search misses them.
