Skip to content

Variable: CSS_IDENTIFIER ​

ts
const CSS_IDENTIFIER: Regex<"(?<identifier>[a-zA-Z_\\u0080-\\uFFFF][\\w\\-\\u0080-\\uFFFF]*)", {
  names: {
     identifier: string;
  };
}>;

Defined in: packages/regex/src/tiers/css-spec.ts:28

CSS identifier from W3C formal grammar. Starts with letter, underscore, or non-ASCII; followed by word chars, hyphens, non-ASCII. Pattern: {ident} → [a-zA-Z_\u0080-\uFFFF][\w\-\u0080-\uFFFF]*

Example ​

ts
CSS_IDENTIFIER.exec("my-class")?.groups?.identifier // "my-class"
CSS_IDENTIFIER.exec("_private")?.groups?.identifier // "_private"
CSS_IDENTIFIER.exec("🎨color")?.groups?.identifier // "🎨color"

Released under the MIT License