Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/terance-edmonds/python-regex
Simple RegEx pattern matching algorithm with Python
https://github.com/terance-edmonds/python-regex
python regex-pattern string-pattern-matching
Last synced: about 2 months ago
JSON representation
Simple RegEx pattern matching algorithm with Python
- Host: GitHub
- URL: https://github.com/terance-edmonds/python-regex
- Owner: terance-edmonds
- Created: 2023-07-28T08:47:52.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-08-04T04:27:51.000Z (over 1 year ago)
- Last Synced: 2023-08-14T17:14:53.961Z (over 1 year ago)
- Topics: python, regex-pattern, string-pattern-matching
- Language: Python
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
Awesome Lists containing this project
README
# Simple Regular Expression Algorithm (RegEx)
This is a simple regular expression (RegEx) algorithm developed with python.
It supports:
- Literals ( abc )
- Ranges ( [a-z], [A-Z], [0-9], [a-zA-Z0-9] )
- Alternatives ( a|b )
- Matching in the middle of a string## Usage
To run a string against the regular expression, create a new object of `RegEx` with the expression or the pattern as its parameter.
Then by using the `match` function of the `RegEx` object pass the string as its parameter and get the result.
```python
from regex import RegExre = RegEx("[a-z0-9]@[a-z].(com|net|org)")
result = re.match("[email protected]")
# output: Trueresult = re.match("[email protected]")
# output: Falseresult = re.match("Hello99@gmailcom")
# output: False
```There are some test cases in `tests.py` file. Use the below code to run the test cases.
```bash
python tests.py
```