https://github.com/archoleat/reglib
Library with ready-to-use regex
https://github.com/archoleat/reglib
archoleat archoleat-reglib library plugin ready-to-use regex reglib regular-expression regular-expressions
Last synced: 3 months ago
JSON representation
Library with ready-to-use regex
- Host: GitHub
- URL: https://github.com/archoleat/reglib
- Owner: archoleat
- License: mit
- Created: 2025-09-06T17:14:26.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2026-01-06T16:27:34.000Z (6 months ago)
- Last Synced: 2026-01-21T00:21:20.530Z (5 months ago)
- Topics: archoleat, archoleat-reglib, library, plugin, ready-to-use, regex, reglib, regular-expression, regular-expressions
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@archoleat/reglib
- Size: 36.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Regex Library








## Table of Contents
- [Installation](#installtion)
- [List of Regex](#list-of-regex)
- [Contributing](#contributing)
- [License](#license)
This library provides a collection of useful
regular expressions for various use cases.
## Installation
```shell
bun i -D @archoleat/reglib
```
## List of Regex
- 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`.
- EMAIL_REGEX
- Pattern: `^[^\s@]+@[^\s@]+\.[^\s@]+$`.
- Description: Matches email addresses with basic validation.
- Example: Matches `user@example.com`, `test.email@domain.co.uk`,
but not `invalid@`, `@domain.com`, or `user@domain`.
- 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](https://github.com/archoleat/validate-font-file-name)
- IS_MOBILE_REGEX
- Pattern: `Mobi|iP(hone|od|ad)|Android|BlackBerry`.
- Description: Detects mobile devices based on user agent strings.
- Example: Matches `iPhone`, `iPad`, `Android`, `BlackBerry`,
`Mobile Safari`, but not `Windows`, `Macintosh`.
- NAME_REGEX
- Pattern: `^(?!-)[A-Za-z\u00C0-\u017FА-Яа-яЁё\s\-\u3000\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FAF\u3400-\u4DBF]+(?