Skip to content

Commit

Permalink
Add documentation for Regex
Browse files Browse the repository at this point in the history
  • Loading branch information
scravy committed Jan 16, 2021
1 parent 2ae02b3 commit 72fd95c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ match("abc", Length(at_least=2, at_most=4))

### `Contains(item)`

Matches an object if it contains the given item.
Matches an object if it contains the given item (as per the same logic as the `in` operator).

```python
match("hello there, world", Contains("there"))
Expand All @@ -650,6 +650,16 @@ match({'foo': 1, 'bar': 2}, Contains('quux') | Contains('bar'))
```


### `Regex(regex_pattern, bind_groups: bool = False)`

Matches a string if it completely matches the given regex, as per `re.fullmatch`.
If the regular expression pattern contains named capturing groups and `bind_groups` is set to `True`,
this pattern will bind the captured results in the `MatchResult`.

To mimic `re.match` or `re.search` the given regular expression `x` can be augmented as `x.*` or `.*x.*`
respectively.


### `Check(predicate)`

Matches an object if it satisfies the given predicate.
Expand Down

0 comments on commit 72fd95c

Please sign in to comment.