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.1.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

verbex-2.0.1-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: verbex-2.0.1.tar.gz
  • Upload date:
  • Size: 23.6 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.1.tar.gz
Algorithm Hash digest
SHA256 4b664898c6b8bbce9033d7a3d7d3c674e491a44dee42d0383f770e4de91d9014
MD5 5f5ef6057da38db3083071332385ae73
BLAKE2b-256 9b461122ae5717a82b4fc7e05719f3049ff95c9b3140fbedded4945a6bca73c6

See more details on using hashes here.

File details

Details for the file verbex-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: verbex-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 19.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7eb5eba79fe482d3ab7937830bca83ab15351c9c29414c58a29138321575c52c
MD5 94a03c22d48da981dcff1f7d9f76fdb9
BLAKE2b-256 154c2e16e97558f50ed55dff4caf0a432225e62d73a74cf8ee1a26ef73541add

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