Skip to main content

Python verbal based regular expressions

Project description

Verbex: Python verbal based regular expressions

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

Installation

pip install Verbex

Usage

from verbex import Verbex
verbex = Verbex()

Documentation

API

Examples

Testing if we have a valid URL

# 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 re.match(test_url.regex,test_url):
    print("Valid URL")

# Print the generated regex
print(tester) # => ^(http)(s)?(\:\/\/)(www\.)?([^\ ]*)$

Replacing strings

# 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 using re
import re
regexp = expression.compile()
result_re = regexp.sub('duck', replace_me)
print(result_re)

Developer setup : running the tests

python setup.py develop
python setup.py test

Other implementations

You can view all implementations on VerbalExpressions.github.io

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

verbex-2.0.2.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

Verbex-2.0.2-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file verbex-2.0.2.tar.gz.

File metadata

  • Download URL: verbex-2.0.2.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for verbex-2.0.2.tar.gz
Algorithm Hash digest
SHA256 f6f00fe2456bf13abf8b663a0796a1c6bbb9254f55ed0de7582eacebc4d20f5b
MD5 7d7597e3f2c33cdbcd35703fc71211d5
BLAKE2b-256 71b37dfac21b0e51de3d6ab0c26867520fe8420a704f8c036107b8b297c61f39

See more details on using hashes here.

File details

Details for the file Verbex-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: Verbex-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for Verbex-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f77a3c26692ef4b34f0e9b1d739b7b5d3017a16cdd6cad71915e802cb469185f
MD5 a5c6c1b2cfd1bb2fa6c53aa58668f46f
BLAKE2b-256 fdf7e7ca357dd7f2f7ef57b2b1b7d52cec5784a2140109bf6d3b0517c5968090

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page