https://github.com/alvarofpp/mre
Maker Regular Expressions.
https://github.com/alvarofpp/mre
maker python-3 regex regular-expression
Last synced: about 2 months ago
JSON representation
Maker Regular Expressions.
- Host: GitHub
- URL: https://github.com/alvarofpp/mre
- Owner: alvarofpp
- License: mit
- Created: 2018-11-05T14:21:50.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-02-06T23:19:35.000Z (about 2 years ago)
- Last Synced: 2025-04-15T01:44:58.107Z (about 1 year ago)
- Topics: maker, python-3, regex, regular-expression
- Language: Python
- Homepage:
- Size: 140 KB
- Stars: 8
- Watchers: 1
- Forks: 11
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Maker Regular Expression
This is a simple package to make regular expressions in Python.
```bash
pip install mre
```
- Test regex: [Regex101](https://regex101.com/);
- [Regular expression operations](https://docs.python.org/3/library/re.html).
## Documentation
- [da-DK :denmark:](docs/da_DK.md) (v. 0.8)
- [de-DE :de:](docs/de_DE.md) (v. 0.8)
- [en-US :us:](docs/en_US.md) (v. 0.9)
- [es-ES :es:](docs/es_ES.md) (v. 0.8)
- [pt-BR :brazil:](docs/pt_BR.md) (v. 0.11)
- [ru-RU :ru:](docs/ru_RU.md) (v. 0.8)
- [uk-UA :ukraine:](docs/uk_UA.md) (v. 0.8)
## Examples
```python
from mre import Regex, Group
rgx_one = Regex("Hello world") # Hello world
rgx_two = Regex("Hello", " world") # Hello world
rgx_three = Regex("Hello") + " " + Regex("world") # Hello world
rgx_four = Regex('<', Group('h[1-6]'), '>') # <(h[1-6])>
rgx_five = Regex('<', Regex.SLASH, 1, '>') # <\/\1>
```
```python
from mre import Set
from mre.helper import Range
# All digits
digits = Set(Range(0, 9))
# Add comment
digits = digits.comment('Get all digits')
# Output: [0-9](?#Get all digits)
```
```python
from mre import Regex, Set, Comment
# All digits
digits = Set(Regex("0-9"))
# CEP comment
cep_comment = Comment('Get zip code Brazil on input')
# CEP regex
rgx_cep = Regex(
digits.quantifier(5),
Regex("-").quantifier(0, 1),
digits.quantifier(3),
cep_comment
)
# Output: [0-9]{5}-?[0-9]{3}(?#Get zip code Brazil on input)
```
## Tests
To test the package just run the following command:
```shell
# (first time only) Build the Docker image
make build
# Run tests
make test
# Run tests and check coverage
make test-coverage
```
## Contributing
Contributions are more than welcome. Fork, improve and make a pull request.
For bugs, ideas for improvement or other, please create an [issue][issues].
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
[issues]: https://github.com/alvarofpp/mre/issues