Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@archoleat/reglib

archoleat625MIT1.8.0TypeScript support: included

Library with ready-to-use regex

archoleat-reglib, archoleat, library, plugin, ready-to-use, regex, reglib, regular-expression, regular-expressions

readme

Regex Library

NPM Version NPM Downloads Specs Commitlint Editorconfig Prettier ESLint Remark

Table of Contents

Installation

bun i -D @archoleat/reglib

List of Regex

This library provides a collection of useful regular expressions for various use cases. Below is a list of the exported regex patterns along with their explanations:

  • ATTRIBUTE_REGEX

    • Pattern: \[[^\]]+\].
    • Description: Matches an attribute in square brackets.
    • Example: Matches [attr], [data-test], but not [attr or attr].
  • CLASS_REGEX

    • Pattern: \.[a-z0-9_-]+.
    • Description: Matches a CSS class name starting with a dot (.).
    • Example: Matches .class, .my-class, .class_name, but not class or .class!.
  • BLOCK_REGEX

    • Pattern: [a-z][a-z0-9]*(-[a-z0-9]+)*.
    • Description: Matches a BEM block name.
    • Example: Matches block, my-block, block-name, but not Block or block!.
  • ELEMENT_REGEX

    • Pattern: (__[a-z0-9]+(-[a-z0-9]+)*).
    • Description: Matches a BEM element name.
    • Example: Matches __element, __my-element, but not element or __element!.
  • MODIFIER_REGEX

    • Pattern: (--[a-z0-9]+(-[a-z0-9]+)*).
    • Description: Matches a BEM modifier name.
    • Example: Matches --modifier, --my-modifier, but not modifier or --modifier!.
  • SIBLING_REGEX

    • Pattern: (?:[^ ,{}]+\s*)?\+\s*[^ ,{}]+.
    • Description: Matches a sibling selector in CSS.
    • Example: Matches + p, div + p, .class + .another-class, but not div > p.
  • CHILD_REGEX

    • Pattern: (?:[^ ,{}]+\s*)?>\s*[^ ,{}]+.
    • Description: Matches a child selector in CSS.
    • Example: Matches > p, div > p, .class > .another-class, but not div + p.
  • ATTRIBUTE_SIBLING_REGEX

    • Pattern: \[[^\]]+\]\s*\+\s*[^ ,{}]+.
    • Description: Matches an attribute selector followed by a sibling selector.
    • Example: Matches [attr] + div, [data-test] + .class.
  • ATTRIBUTE_CHILD_REGEX

    • Pattern: \[[^\]]+\]\s*>\s*[^ ,{}]+.
    • Description: Matches an attribute selector followed by a child selector.
    • Example: Matches [attr] > div, [data-test] > .class.
  • CLASS_SIBLING_REGEX

    • Pattern: \.[a-z0-9_-]+\s*\+\s*[^ ,{}]+.
    • Description: Matches a class selector followed by a sibling selector.
    • Example: Matches .class + div, .my-class + .another-class.
  • CLASS_CHILD_REGEX

    • Pattern: \.[a-z0-9_-]+\s*>\s*[^ ,{}]+.
    • Description: Matches a class selector followed by a child selector.
    • Example: Matches .class > div, .my-class > .another-class.
  • NESTED_ATTRIBUTE_SIBLING_REGEX

    • Pattern: &\[[^\]]+\]\s*\+\s*[^ ,{}]+.

    • Description: Matches a nested attribute selector followed by a sibling selector.

    • Example: Matches &[attr] + div, &[data-test] + .class.

  • NESTED_ATTRIBUTE_CHILD_REGEX

    • Pattern: &\[[^\]]+\]\s*>\s*[^ ,{}]+.

    • Description: Matches a nested attribute selector followed by a child selector.

    • Example: Matches &[attr] > div, &[data-test] > .class.

  • NESTED_CLASS_SIBLING_REGEX

    • Pattern: &\.[a-z0-9_-]+\s*\+\s*[^ ,{}]+.
    • Description: Matches a nested class selector followed by a sibling selector.
    • Example: Matches &.class + div, &.my-class + .another-class.
  • NESTED_CLASS_CHILD_REGEX

    • Pattern: &\.[a-z0-9_-]+\s*>\s*[^ ,{}]+.
    • Description: Matches a nested class selector followed by a child selector.
    • Example: Matches &.class > div, &.my-class > .another-class.
  • NESTED_ATTRIBUTE_REGEX

    • Pattern: &\[[^\]]+\].
    • Description: Matches a nested attribute selector.
    • Example: Matches &[attr], &[data-test].
  • NESTED_CLASS_REGEX

    • Pattern: &\.[a-z0-9_-]+.
    • Description: Matches a nested class selector.
    • Example: Matches &.class, &.my-class.
  • FONT_FILE_NAME_REGEX

    • Pattern: A complex regex for matching font file names.

    • Description: Matches font file names based on family, weight, italic, variable, and extension.

    • Example: Matches Roboto-Bold.woff2, OpenSans-Italic-Variable.ttf.

      More info validate-font-file-name

Contributing

Please read CONTRIBUTING to start contributing.

License

This project is licensed under the MIT license.

changelog

Changelog

1.8.0 (2025-01-16)

Features

1.7.0 (2025-01-14)

Features

1.6.0 (2025-01-14)

⚠ BREAKING CHANGES

  • regex (#126)

Features

1.5.4 (2025-01-14)

Code Refactoring

1.5.3 (2025-01-14)

Bug Fixes

1.5.2 (2025-01-14)

Bug Fixes

Code Refactoring

1.5.1 (2025-01-12)

Bug Fixes

Code Refactoring

1.5.0 (2025-01-11)

Features

1.4.0 (2025-01-11)

Features

Bug Fixes

1.3.1 (2025-01-11)

Code Refactoring

1.3.0 (2025-01-11)

⚠ BREAKING CHANGES

  • migrate to bun (#107)

Features

Bug Fixes

Code Refactoring

1.2.1 (2024-12-08)

Bug Fixes

Code Refactoring

Documentation

1.2.0 (2024-11-11)

Features

1.1.0 (2024-07-31)

Features

Bug Fixes

1.0.3 (2024-07-31)

Bug Fixes

1.0.2 (2024-07-31)

Bug Fixes

1.0.1 (2024-07-31)

Bug Fixes

1.0.0 (2024-07-31)

Features