diff options
| author | natsuoto <[email protected]> | 2026-07-11 16:00:07 +0530 |
|---|---|---|
| committer | natsuoto <[email protected]> | 2026-07-11 16:00:07 +0530 |
| commit | 08f21e26b8dfb4a4d8dc4c7e563f99a9a6d241e6 (patch) | |
| tree | e76f12eb4156e014a3291d94c2f4c49d48c5cb82 | |
| parent | dfb277b8b814e8106fff1e5424f4685471417516 (diff) | |
| download | edify-08f21e26b8dfb4a4d8dc4c7e563f99a9a6d241e6.tar.xz edify-08f21e26b8dfb4a4d8dc4c7e563f99a9a6d241e6.zip | |
feat(library/text): 11 text patterns (slug, base, script, ascii, printable, alphanumeric, alpha, numeric, word, unicode, emoji)
| -rw-r--r-- | edify/library/text/__init__.py | 16 | ||||
| -rw-r--r-- | edify/library/text/alpha.py | 8 | ||||
| -rw-r--r-- | edify/library/text/alphanumeric.py | 8 | ||||
| -rw-r--r-- | edify/library/text/ascii.py | 10 | ||||
| -rw-r--r-- | edify/library/text/base.py | 18 | ||||
| -rw-r--r-- | edify/library/text/emoji.py | 10 | ||||
| -rw-r--r-- | edify/library/text/numeric.py | 8 | ||||
| -rw-r--r-- | edify/library/text/printable.py | 10 | ||||
| -rw-r--r-- | edify/library/text/script.py | 21 | ||||
| -rw-r--r-- | edify/library/text/slug.py | 10 | ||||
| -rw-r--r-- | edify/library/text/unicode.py | 8 | ||||
| -rw-r--r-- | edify/library/text/word.py | 10 |
12 files changed, 137 insertions, 0 deletions
diff --git a/edify/library/text/__init__.py b/edify/library/text/__init__.py new file mode 100644 index 0000000..aeb116b --- /dev/null +++ b/edify/library/text/__init__.py @@ -0,0 +1,16 @@ +from edify.library.text.alpha import alpha +from edify.library.text.alphanumeric import alphanumeric +from edify.library.text.ascii import ascii +from edify.library.text.base import base +from edify.library.text.emoji import emoji +from edify.library.text.numeric import numeric +from edify.library.text.printable import printable +from edify.library.text.script import script +from edify.library.text.slug import slug +from edify.library.text.unicode import unicode +from edify.library.text.word import word + +__all__ = [ + "alpha", "alphanumeric", "ascii", "base", "emoji", "numeric", + "printable", "script", "slug", "unicode", "word", +] diff --git a/edify/library/text/alpha.py b/edify/library/text/alpha.py new file mode 100644 index 0000000..ea5f78f --- /dev/null +++ b/edify/library/text/alpha.py @@ -0,0 +1,8 @@ +"""``alpha`` — letters-only string shape.""" + +from __future__ import annotations + +from edify.library._support.regex import RegexBackedPattern + +alpha = RegexBackedPattern(r"^[A-Za-z]+$") +"""Callable :class:`Pattern` for a letters-only string.""" diff --git a/edify/library/text/alphanumeric.py b/edify/library/text/alphanumeric.py new file mode 100644 index 0000000..7bc6fad --- /dev/null +++ b/edify/library/text/alphanumeric.py @@ -0,0 +1,8 @@ +"""``alphanumeric`` — letters-and-digits-only string shape.""" + +from __future__ import annotations + +from edify.library._support.regex import RegexBackedPattern + +alphanumeric = RegexBackedPattern(r"^[A-Za-z0-9]+$") +"""Callable :class:`Pattern` for a letters-and-digits-only string.""" diff --git a/edify/library/text/ascii.py b/edify/library/text/ascii.py new file mode 100644 index 0000000..da92912 --- /dev/null +++ b/edify/library/text/ascii.py @@ -0,0 +1,10 @@ +"""``ascii`` — printable-ASCII-only string shape.""" + +from __future__ import annotations + +from edify.library._support.regex import RegexBackedPattern + +ascii = RegexBackedPattern(r"^[\x20-\x7E]+$") +"""Callable :class:`Pattern` for a printable-ASCII-only string +(characters ``0x20``–``0x7E``). +""" diff --git a/edify/library/text/base.py b/edify/library/text/base.py new file mode 100644 index 0000000..526d94e --- /dev/null +++ b/edify/library/text/base.py @@ -0,0 +1,18 @@ +"""``base`` — base16 / base32 / base58 / base64 / base64url encoded string shape.""" + +from __future__ import annotations + +from edify.library._support.regex import RegexBackedPattern + +base = RegexBackedPattern( + r"^(?:" + r"[0-9A-Fa-f]+" + r"|[A-Z2-7]+=*" + r"|[1-9A-HJ-NP-Za-km-z]+" + r"|[A-Za-z0-9+/]+=*" + r"|[A-Za-z0-9_-]+" + r")$" +) +"""Callable :class:`Pattern` that accepts any of base16, base32, base58, +base64, or base64url encoded strings. +""" diff --git a/edify/library/text/emoji.py b/edify/library/text/emoji.py new file mode 100644 index 0000000..a076cc8 --- /dev/null +++ b/edify/library/text/emoji.py @@ -0,0 +1,10 @@ +"""``emoji`` — one-or-more emoji-character shape.""" + +from __future__ import annotations + +from edify.library._support.regex import RegexBackedPattern + +emoji = RegexBackedPattern( + r"^[\U0001F300-\U0001FAFF☀-➿]+$" +) +"""Callable :class:`Pattern` for a run of one or more emoji characters.""" diff --git a/edify/library/text/numeric.py b/edify/library/text/numeric.py new file mode 100644 index 0000000..1bc5485 --- /dev/null +++ b/edify/library/text/numeric.py @@ -0,0 +1,8 @@ +"""``numeric`` — digits-only string shape.""" + +from __future__ import annotations + +from edify.library._support.regex import RegexBackedPattern + +numeric = RegexBackedPattern(r"^\d+$") +"""Callable :class:`Pattern` for a digits-only string.""" diff --git a/edify/library/text/printable.py b/edify/library/text/printable.py new file mode 100644 index 0000000..f729e91 --- /dev/null +++ b/edify/library/text/printable.py @@ -0,0 +1,10 @@ +"""``printable`` — printable-character string shape (excludes control codes).""" + +from __future__ import annotations + +from edify.library._support.regex import RegexBackedPattern + +printable = RegexBackedPattern(r"^[^\x00-\x1F\x7F]+$") +"""Callable :class:`Pattern` for a printable-character string +(excludes ASCII control codes). +""" diff --git a/edify/library/text/script.py b/edify/library/text/script.py new file mode 100644 index 0000000..0c720e2 --- /dev/null +++ b/edify/library/text/script.py @@ -0,0 +1,21 @@ +"""``script`` — text in a specific Unicode script (Latin/Cyrillic/Greek/CJK/etc.).""" + +from __future__ import annotations + +from edify.library._support.regex import RegexBackedPattern + +script = RegexBackedPattern( + r"^(?:" + r"[A-Za-zÀ-ɏ]+" + r"|[Ѐ-ӿ]+" + r"|[Ͱ-Ͽ]+" + r"|[一-鿿-ゟ゠-ヿ가-]+" + r"|[-ۿ]+" + r"|[-]+" + r"|[ऀ-ॿ]+" + r")$" +) +"""Callable :class:`Pattern` for text in a single common Unicode script: +Latin (with extensions), Cyrillic, Greek, CJK (Chinese/Japanese/Korean), +Arabic, Hebrew, or Devanagari. +""" diff --git a/edify/library/text/slug.py b/edify/library/text/slug.py new file mode 100644 index 0000000..7d45a76 --- /dev/null +++ b/edify/library/text/slug.py @@ -0,0 +1,10 @@ +"""``slug`` — URL-safe slug shape.""" + +from __future__ import annotations + +from edify.library._support.regex import RegexBackedPattern + +slug = RegexBackedPattern(r"^[a-z0-9]+(?:-[a-z0-9]+)*$") +"""Callable :class:`Pattern` for a URL-safe slug: lowercase alphanumerics +separated by single hyphens. +""" diff --git a/edify/library/text/unicode.py b/edify/library/text/unicode.py new file mode 100644 index 0000000..cc1eacd --- /dev/null +++ b/edify/library/text/unicode.py @@ -0,0 +1,8 @@ +"""``unicode`` — any Unicode-letter-or-digit string shape.""" + +from __future__ import annotations + +from edify.library._support.regex import RegexBackedPattern + +unicode = RegexBackedPattern(r"^[^\x00-\x1F\x7F]+$") +"""Callable :class:`Pattern` for any Unicode string containing no control codes.""" diff --git a/edify/library/text/word.py b/edify/library/text/word.py new file mode 100644 index 0000000..44ee068 --- /dev/null +++ b/edify/library/text/word.py @@ -0,0 +1,10 @@ +"""``word`` — Python word-character string shape (``\\w+``).""" + +from __future__ import annotations + +from edify.library._support.regex import RegexBackedPattern + +word = RegexBackedPattern(r"^\w+$") +"""Callable :class:`Pattern` for a word-character string: +letters, digits, and underscores. +""" |
