Skip to main content

RegexSolver allows you to manipulate regular expressions as sets, enabling operations such as intersection, union, and subtraction.

Project description

RegexSolver Python API Client

Homepage | Documentation | Developer Console

This repository contains the source code of the Python library for RegexSolver API.

RegexSolver is a powerful regular expression manipulation toolkit, that gives you the power to manipulate regex as if they were sets.

Installation

pip install --upgrade regexsolver

Requirements

  • Python >=3.7

Usage

In order to use the library you need to generate an API Token on our Developer Console.

from regexsolver import RegexSolver, Term

RegexSolver.initialize("YOUR TOKEN HERE")

term1 = Term.regex(r"(abc|de|fg){2,}")
term2 = Term.regex(r"de.*")
term3 = Term.regex(r".*abc")

term4 = Term.regex(r".+(abc|de).+")

result = term1.intersection(term2, term3)\
              .subtraction(term4)

print(result)

Features

Intersection

Request

Compute the intersection of the provided terms and return the resulting term.

The maximum number of terms is currently limited to 10.

term1 = Term.regex(r"(abc|de){2}")
term2 = Term.regex(r"de.*")
term3 = Term.regex(r".*abc")

result = term1.intersection(term2, term3)
print(result)

Response

regex=deabc

Union

Compute the union of the provided terms and return the resulting term.

The maximum number of terms is currently limited to 10.

Request

term1 = Term.regex(r"abc")
term2 = Term.regex(r"de")
term3 = Term.regex(r"fghi")

result = term1.union(term2, term3)
print(result)

Response

regex=(abc|de|fghi)

Subtraction / Difference

Compute the first term minus the second and return the resulting term.

Request

term1 = Term.regex(r"(abc|de)")
term2 = Term.regex(r"de")

result = term1.subtraction(term2)
print(result)

Response

regex=abc

Equivalence

Analyze if the two provided terms are equivalent.

Request

term1 = Term.regex(r"(abc|de)")
term2 = Term.regex(r"(abc|de)*")

result = term1.is_equivalent_to(term2)
print(result)

Response

False

Subset

Analyze if the second term is a subset of the first.

Request

term1 = Term.regex(r"de")
term2 = Term.regex(r"(abc|de)")

result = term1.is_subset_of(term2)
print(result)

Response

True

Details

Compute the details of the provided term.

The computed details are:

  • Cardinality: the number of possible values.
  • Length: the minimum and maximum length of possible values.
  • Empty: true if is an empty set (does not contain any value), false otherwise.
  • Total: true if is a total set (contains all values), false otherwise.

Request

term = Term.regex(r"(abc|de)")

details = term.get_details()
print(details)

Response

Details[cardinality=Integer(2), length=Length[minimum=2, maximum=3], empty=false, total=false]

Generate Strings

Generate the given number of strings that can be matched by the provided term.

The maximum number of strings to generate is currently limited to 200.

Request

term = Term.regex(r"(abc|de){2}")

strings = term.generate_strings(3)
print(strings)

Response

['deabc', 'abcde', 'dede']

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

regexsolver-1.0.3.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

regexsolver-1.0.3-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file regexsolver-1.0.3.tar.gz.

File metadata

  • Download URL: regexsolver-1.0.3.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for regexsolver-1.0.3.tar.gz
Algorithm Hash digest
SHA256 45af2e832c7ab60a5acdb4abd8812193f3f7ff9b2cc4f3381b550df9102f40c1
MD5 7313bcd25ba122f0027e47c5f5070bb7
BLAKE2b-256 a10c1e9a39c5831447d9eb693441bf6dd00816f5920da1869ab130655de6f826

See more details on using hashes here.

File details

Details for the file regexsolver-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: regexsolver-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for regexsolver-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bd232a7d5b8aeb6adbf27b1eb7420685e0cc937aafc62c9ffb7ad40e9e3b4d8e
MD5 9174e99854e0578cb79a199c54250342
BLAKE2b-256 a7b477f25d831601eb8b1cc5d0d93eaa47196021ff726071483af1a794dc0238

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