Skip to main content

Verbex: Python verbal based regular expressions

Generic badge Code style: black PyPI pyversions Generic badge Generic badge Generic badge Generic badge Dynamic TOML Badge

Installation

pip install Verbex

Notes

  • Verbex now depends on the regex package (instead of Python's built-in re engine) for faster and more expressive pattern evaluation.
  • Quantifier methods default to possessive mode for performance (maybe, zero_or_more, one_or_more, n_times, n_times_or_more, n_to_m_times, anything).
  • If you need legacy backtracking behavior, pass possessive=False.
  • You can set the default quantifier behavior once per expression with Verbex(default_possessive=False).
  • OR(...) alternates only against the most recently added fragment. Use or_expr(...) to alternate against the full expression.

Usage

from verbex import Verbex
verbex = Verbex()

Documentation

API

Examples

Testing if we have a valid URL

from verbex import Verbex

# Create an example of how to test for correctly formed URLs
verbex = Verbex()
tester = (verbex.
            start_of_line().
            find('http').
            maybe('s').
            find('://').
            maybe('www.').
            anything_but(' ').
            end_of_line()
)

# Create an example URL
test_url = "https://www.google.com"

# Test if the URL is valid
if tester.regex().fullmatch(test_url):
    print("Valid URL")

# Print the generated regex
print(tester)  # Example: ^http?+://(?:www\.)?+[^ ]+$

Replacing strings

from verbex import Verbex

# Create a test string
replace_me = "Replace bird with a duck"

# Create an expression that looks for the word "bird"
expression = Verbex().find('bird')

# Compile and use the regular expression
regexp = expression.regex()
result_re = regexp.sub('duck', replace_me)
print(result_re)

Developer setup : running the tests

just tests

Other implementations

You can view all implementations on VerbalExpressions.github.io

Metadata

Release files for Verbex 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Verbex 3.0.0
File Size Uploaded
verbex-3.0.0.tar.gz 25.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Verbex 3.0.0
File Interpreter ABI Platform
verbex-3.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 46.1 kB

Release files / verbex-3.0.0.tar.gz

Download URL verbex-3.0.0.tar.gz
Size 25.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c9a51dc5471142e972bf0f0ed8f6fb51ddab6e5c8b68375b6739ad4f112d7ba0
BLAKE2b-256 checksum
How to use checksums
3badaea282fdc707a27f9fd1f2a2251a5037cbc75da7e95b0e6cd4b53c9356d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / verbex-3.0.0-py3-none-any.whl

Download URL verbex-3.0.0-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c447f928521273a8e95ca6b9e3e7bc14a29521bd21cdd03b2929282aec2b5058
BLAKE2b-256 checksum
How to use checksums
e2113d34d241c6c84a3d760031be96fca18682628210d23b11ee2793f2cb8403
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 release files

2.0.2

2 release files

2.0.1

2 release files

1.2.0

2 release files

1.1.0

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page