aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-02-04 13:44:38 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-02-04 13:44:38 -0500
commit50edc4097a648dd2864ed665343d8de606a8f4a2 (patch)
treef1f61bd84907f79a402c59dce4f35e8a0ddebf68
parent0d8d109eaf56aaea4b8826c344056ee4dc801709 (diff)
Add {word} as an alias for {id}
-rw-r--r--docs/text.md1
-rw-r--r--stdlib/patterns.c5
2 files changed, 6 insertions, 0 deletions
diff --git a/docs/text.md b/docs/text.md
index c8a105d5..3e6ed0dc 100644
--- a/docs/text.md
+++ b/docs/text.md
@@ -337,6 +337,7 @@ mostly ignore spaces, underscores, and dashes.
- `start` - the very start of the text
- `uri` - a URI
- `url` - a URL (URI that specifically starts with `http://`, `https://`, `ws://`, `wss://`, or `ftp://`)
+- `word` - A unicode identifier (same as `id`)
For non-alphabetic characters, any single character is treated as matching
exactly that character. For example, `{1{}` matches exactly one `{`
diff --git a/stdlib/patterns.c b/stdlib/patterns.c
index bee84760..6a9b1a50 100644
--- a/stdlib/patterns.c
+++ b/stdlib/patterns.c
@@ -654,6 +654,11 @@ static pat_t parse_next_pat(TextIter_t *state, int64_t *index)
return PAT(PAT_FUNCTION, .fn=match_url);
}
break;
+ case 'w':
+ if (strcasecmp(prop_name, "word") == 0) {
+ return PAT(PAT_FUNCTION, .fn=match_id);
+ }
+ break;
default: break;
}