diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-01 20:08:36 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-01 20:08:36 -0400 |
| commit | dd4c25e6b768e39fbcd437e44f80dc958e1f5869 (patch) | |
| tree | 013c42119866c574980fae7a3323d9ace3eafc0a /examples/patterns/patterns.c | |
| parent | 57ff9fdfc6b557211052aa275bfcca3e2316a0c6 (diff) | |
Update patterns API and docs
Diffstat (limited to 'examples/patterns/patterns.c')
| -rw-r--r-- | examples/patterns/patterns.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/examples/patterns/patterns.c b/examples/patterns/patterns.c index ade68e04..180ab431 100644 --- a/examples/patterns/patterns.c +++ b/examples/patterns/patterns.c @@ -851,7 +851,14 @@ PUREFUNC static bool Pattern$has(Text_t text, Text_t pattern) } } -static OptionalArray_t Pattern$matches(Text_t text, Text_t pattern) +static bool Pattern$matches(Text_t text, Text_t pattern) +{ + capture_t captures[MAX_BACKREFS] = {}; + int64_t match_len = match(text, 0, pattern, 0, NULL, 0); + return (match_len == text.length); +} + +static OptionalArray_t Pattern$captures(Text_t text, Text_t pattern) { capture_t captures[MAX_BACKREFS] = {}; int64_t match_len = match(text, 0, pattern, 0, captures, 0); |
