Skip to main content

Make difficult regular expressions easy! Python fork based on of the awesome VerbalExpressions repo - https://github.com/jehna/VerbalExpressions

Project description

Verbex: Python verbal based regular expressions

Build Status Code style: black

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

Uploaded Source

Built Distribution

Verbex-1.2.0-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file Verbex-1.2.0.tar.gz.

File metadata

  • Download URL: Verbex-1.2.0.tar.gz
  • Upload date:
  • Size: 157.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for Verbex-1.2.0.tar.gz
Algorithm Hash digest
SHA256 70f697037b6e1f06eb469a245dc2944f2e70fcaf10497bef91aa090171a2ceaf
MD5 041f4f6bf175b0a3d7933af8b0546b6f
BLAKE2b-256 018958bd0be5f16d8756a0261620caca3a49730824caf35c454c8964d5547e5f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: Verbex-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for Verbex-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51916fd1d00482d7a735d42e42bca0070edd5dd3ffb94a2c7a2f5bea3cd04568
MD5 86be2665093fa01c977fc804ac12241c
BLAKE2b-256 0d15b4a01dd2eb311aa5c3e9f50686baf20352254c091db780a4611b824df5f0

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