diff options
| author | 夏音 / natsuoto.exe <[email protected]> | 2026-07-01 16:05:12 +0530 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-07-01 16:05:12 +0530 |
| commit | a757473f3551426948069a1a25ef6657a572d759 (patch) | |
| tree | b4ea0ae364450cd76cd81ae3cda4c466cd91b8cc /tests/errors | |
| parent | a3647c5bde1ae63e1af6316b353949365c49f774 (diff) | |
| parent | 48554b6e049cd845ab7caa6321b5976ab3becd85 (diff) | |
| download | edify-a757473f3551426948069a1a25ef6657a572d759.tar.xz edify-a757473f3551426948069a1a25ef6657a572d759.zip | |
feat: .test() boolean shortcut on Pattern and RegexBuilder (#264)
Adds the last convenience terminal from #127: `.test(string) -> bool` on
both `Pattern` and `RegexBuilder`.
## What is new
- `test(string, pos=0, endpos=sys.maxsize) -> bool` on `MatcherMixin` —
returns `True` when the pattern matches anywhere in the input, else
`False`. Semantically `self.to_regex().search(...) is not None`.
## Why
PR #263 already delivered `.match`, `.search`, `.fullmatch`, `.findall`,
`.finditer`, `.sub`, `.subn`, `.split` from the #127 wishlist. `.test` —
a boolean shortcut idiomatic in Ruby/humre/JS — was the only piece
missing.
## Example
```python
from edify import DIGIT, START, END, exactly
zip_code = START + exactly(5, DIGIT) + END
zip_code.test("10001") # True
zip_code.test("nope") # False
```
Closes #127
Diffstat (limited to 'tests/errors')
0 files changed, 0 insertions, 0 deletions
