alvarofpp / alvarofpp/mre

Or (A|B)

Open
#9 1 comment 0 reactions 0 assignees View on GitHub
enhancement hacktoberfest
Dominant language
Python
Stars
8
Forks
10
PR merge metrics
No merged PRs in 30d

Description

[`A|B`](https://docs.python.org/3.7/library/re.html#index-13)

**Normal regex**:
```py
from mre import Regex

# Example of how it can work
print(Regex('Test').or(Regex('test')))

# Output: Test|test
# Regex without |: Testtest
```
![or-1](https://user-images.githubusercontent.com/10817238/65912881-51067f00-e3a5-11e9-945d-263b57502069.png)

**Group**:
```py
from mre import Regex, Group

# Example of how it can work
print(Group('Test').or(Regex('test')))

# Output: (Test|test)
# Regex without |: (Testtest)
```
![or-group](https://user-images.githubusercontent.com/10817238/65912882-519f1580-e3a5-11e9-9e0e-a279af64573c.png)

----------

**Attention** to Set behavior:
```py
from mre import Regex, Set

# Example of how it can work
print(Set('Test').or(Regex('test')))

# Output: [Test|test]
# Regex without |: [Testtest]
```
![or-set-1](https://user-images.githubusercontent.com/10817238/65912883-519f1580-e3a5-11e9-95ba-65e7f918659a.png)
Operator `or` it makes no sense to have the default behavior in this case.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.