Skip to main content

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']

Metadata

Release files for regexsolver 1.0.2

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

Source distribution (sdist)

Source distribution for regexsolver 1.0.2
File Size Uploaded
regexsolver-1.0.2.tar.gz 7.1 kB Details

Built distribution (wheel)

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

Total release size: 13.9 kB

Release files / regexsolver-1.0.2.tar.gz

Download URL regexsolver-1.0.2.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
91fade0d140d7ae3d148e6557e267fa9ba70c21e8e648b433cfad45e2292af9f
BLAKE2b-256 checksum
How to use checksums
95932744ac22505b3f950aecaf0a712a91fff886561b45e2be51bba32af91987
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Release files / regexsolver-1.0.2-py3-none-any.whl

Download URL regexsolver-1.0.2-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f108baba44724087655900c0c142a2d398734bdeda08795aa71e6d34604867de
BLAKE2b-256 checksum
How to use checksums
3c2379e66b2de277901d809999d83320040bb30d68ad9d016157ca871db41695
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Release history Release notifications | RSS feed

1.1.0

2 release files

1.0.3

2 release files

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

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