regexsolver


Nameregexsolver JSON
Version 1.0.3 PyPI version JSON
download
home_pagehttps://github.com/RegexSolver/regexsolver-python
SummaryRegexSolver allows you to manipulate regular expressions as sets, enabling operations such as intersection, union, and subtraction.
upload_time2024-08-11 12:43:59
maintainerNone
docs_urlNone
authorRegexSolver
requires_python>=3.7
licenseMIT License Copyright (c) 2024 RegexSolver Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords regular expression regex regexp set intersection union subtraction difference equivalence subset nfa dfa
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # RegexSolver Python API Client
[Homepage](https://regexsolver.com) | [Documentation](https://docs.regexsolver.com) | [Developer Console](https://console.regexsolver.com)

This repository contains the source code of the Python library for [RegexSolver](https://regexsolver.com) API.

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

## Installation

```sh
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](https://console.regexsolver.com/).

```python
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](#intersection)
- [Union](#union)
- [Subtraction / Difference](#subtraction--difference)
- [Equivalence](#equivalence)
- [Subset](#subset)
- [Details](#details)
- [Generate Strings](#generate-strings)

### Intersection

#### Request

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

The maximum number of terms is currently limited to 10.

```python
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

```python
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

```python
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

```python
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

```java
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

```python
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

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

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

#### Response

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


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/RegexSolver/regexsolver-python",
    "name": "regexsolver",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "Regular Expression, regex, regexp, set, intersection, union, subtraction, difference, equivalence, subset, nfa, dfa",
    "author": "RegexSolver",
    "author_email": "RegexSolver <contact@regexsolver.com>",
    "download_url": "https://files.pythonhosted.org/packages/a1/0c/1e9a39c5831447d9eb693441bf6dd00816f5920da1869ab130655de6f826/regexsolver-1.0.3.tar.gz",
    "platform": null,
    "description": "# RegexSolver Python API Client\n[Homepage](https://regexsolver.com) | [Documentation](https://docs.regexsolver.com) | [Developer Console](https://console.regexsolver.com)\n\nThis repository contains the source code of the Python library for [RegexSolver](https://regexsolver.com) API.\n\nRegexSolver is a powerful regular expression manipulation toolkit, that gives you the power to manipulate regex as if\nthey were sets.\n\n## Installation\n\n```sh\npip install --upgrade regexsolver\n```\n\n### Requirements\n\n- Python >=3.7\n\n## Usage\n\nIn order to use the library you need to generate an API Token on our [Developer Console](https://console.regexsolver.com/).\n\n```python\nfrom regexsolver import RegexSolver, Term\n\nRegexSolver.initialize(\"YOUR TOKEN HERE\")\n\nterm1 = Term.regex(r\"(abc|de|fg){2,}\")\nterm2 = Term.regex(r\"de.*\")\nterm3 = Term.regex(r\".*abc\")\n\nterm4 = Term.regex(r\".+(abc|de).+\")\n\nresult = term1.intersection(term2, term3)\\\n              .subtraction(term4)\n\nprint(result)\n```\n\n## Features\n\n- [Intersection](#intersection)\n- [Union](#union)\n- [Subtraction / Difference](#subtraction--difference)\n- [Equivalence](#equivalence)\n- [Subset](#subset)\n- [Details](#details)\n- [Generate Strings](#generate-strings)\n\n### Intersection\n\n#### Request\n\nCompute the intersection of the provided terms and return the resulting term.\n\nThe maximum number of terms is currently limited to 10.\n\n```python\nterm1 = Term.regex(r\"(abc|de){2}\")\nterm2 = Term.regex(r\"de.*\")\nterm3 = Term.regex(r\".*abc\")\n\nresult = term1.intersection(term2, term3)\nprint(result)\n```\n\n#### Response\n\n```\nregex=deabc\n```\n\n### Union\n\nCompute the union of the provided terms and return the resulting term.\n\nThe maximum number of terms is currently limited to 10.\n\n#### Request\n\n```python\nterm1 = Term.regex(r\"abc\")\nterm2 = Term.regex(r\"de\")\nterm3 = Term.regex(r\"fghi\")\n\nresult = term1.union(term2, term3)\nprint(result)\n```\n\n#### Response\n\n```\nregex=(abc|de|fghi)\n```\n\n### Subtraction / Difference\n\nCompute the first term minus the second and return the resulting term.\n\n#### Request\n\n```python\nterm1 = Term.regex(r\"(abc|de)\")\nterm2 = Term.regex(r\"de\")\n\nresult = term1.subtraction(term2)\nprint(result)\n```\n\n#### Response\n\n```\nregex=abc\n```\n\n### Equivalence\n\nAnalyze if the two provided terms are equivalent.\n\n#### Request\n\n```python\nterm1 = Term.regex(r\"(abc|de)\")\nterm2 = Term.regex(r\"(abc|de)*\")\n\nresult = term1.is_equivalent_to(term2)\nprint(result)\n```\n\n#### Response\n\n```\nFalse\n```\n\n### Subset\n\nAnalyze if the second term is a subset of the first.\n\n#### Request\n\n```java\nterm1 = Term.regex(r\"de\")\nterm2 = Term.regex(r\"(abc|de)\")\n\nresult = term1.is_subset_of(term2)\nprint(result)\n```\n\n#### Response\n\n```\nTrue\n```\n\n### Details\n\nCompute the details of the provided term.\n\nThe computed details are:\n\n- **Cardinality:** the number of possible values.\n- **Length:** the minimum and maximum length of possible values.\n- **Empty:** true if is an empty set (does not contain any value), false otherwise.\n- **Total:** true if is a total set (contains all values), false otherwise.\n\n#### Request\n\n```python\nterm = Term.regex(r\"(abc|de)\")\n\ndetails = term.get_details()\nprint(details)\n```\n\n#### Response\n\n```\nDetails[cardinality=Integer(2), length=Length[minimum=2, maximum=3], empty=false, total=false]\n```\n\n### Generate Strings\n\nGenerate the given number of strings that can be matched by the provided term.\n\nThe maximum number of strings to generate is currently limited to 200.\n\n#### Request\n\n```python\nterm = Term.regex(r\"(abc|de){2}\")\n\nstrings = term.generate_strings(3)\nprint(strings)\n```\n\n#### Response\n\n```\n['deabc', 'abcde', 'dede']\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 RegexSolver  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "RegexSolver allows you to manipulate regular expressions as sets, enabling operations such as intersection, union, and subtraction.",
    "version": "1.0.3",
    "project_urls": {
        "Documentation": "https://docs.regexsolver.com/",
        "Homepage": "https://regexsolver.com/",
        "Issues": "https://github.com/RegexSolver/regexsolver-python/issues",
        "Source Code": "https://github.com/RegexSolver/regexsolver-python"
    },
    "split_keywords": [
        "regular expression",
        " regex",
        " regexp",
        " set",
        " intersection",
        " union",
        " subtraction",
        " difference",
        " equivalence",
        " subset",
        " nfa",
        " dfa"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a7b477f25d831601eb8b1cc5d0d93eaa47196021ff726071483af1a794dc0238",
                "md5": "9174e99854e0578cb79a199c54250342",
                "sha256": "bd232a7d5b8aeb6adbf27b1eb7420685e0cc937aafc62c9ffb7ad40e9e3b4d8e"
            },
            "downloads": -1,
            "filename": "regexsolver-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9174e99854e0578cb79a199c54250342",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6795,
            "upload_time": "2024-08-11T12:43:57",
            "upload_time_iso_8601": "2024-08-11T12:43:57.499834Z",
            "url": "https://files.pythonhosted.org/packages/a7/b4/77f25d831601eb8b1cc5d0d93eaa47196021ff726071483af1a794dc0238/regexsolver-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a10c1e9a39c5831447d9eb693441bf6dd00816f5920da1869ab130655de6f826",
                "md5": "7313bcd25ba122f0027e47c5f5070bb7",
                "sha256": "45af2e832c7ab60a5acdb4abd8812193f3f7ff9b2cc4f3381b550df9102f40c1"
            },
            "downloads": -1,
            "filename": "regexsolver-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "7313bcd25ba122f0027e47c5f5070bb7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 7103,
            "upload_time": "2024-08-11T12:43:59",
            "upload_time_iso_8601": "2024-08-11T12:43:59.008994Z",
            "url": "https://files.pythonhosted.org/packages/a1/0c/1e9a39c5831447d9eb693441bf6dd00816f5920da1869ab130655de6f826/regexsolver-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-11 12:43:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "RegexSolver",
    "github_project": "regexsolver-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "regexsolver"
}
        
Elapsed time: 0.30671s