aboutsummaryrefslogtreecommitdiff
path: root/api/text.yaml
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-11-23 00:35:05 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-11-23 00:35:05 -0500
commitcb9d3b1a2c2c59c368f6121a16a9ab928b0ff951 (patch)
treedf4c38c993ff78e2e4005058efb66ee1df6f3561 /api/text.yaml
parenta453ebf215e5e3ec3b27fa5142af77d7e3ca0c92 (diff)
Added Text.find(text, target, start=1)
Diffstat (limited to 'api/text.yaml')
-rw-r--r--api/text.yaml28
1 files changed, 28 insertions, 0 deletions
diff --git a/api/text.yaml b/api/text.yaml
index 2c21fa30..6874bfc8 100644
--- a/api/text.yaml
+++ b/api/text.yaml
@@ -225,6 +225,34 @@ Text.ends_with:
assert "hello world".ends_with("world", &remainder) == yes
assert remainder == "hello "
+Text.find:
+ short: find a substring
+ description: >
+ Find a substring within a text and return its index, if found.
+ return:
+ type: 'Int'
+ description: >
+ The index where the first occurrence of `target` appears, or `none` if it is not found.
+ args:
+ text:
+ type: 'Text'
+ description: >
+ The text to be searched.
+ target:
+ type: 'Text'
+ description: >
+ The target text to find.
+ start:
+ type: 'Int'
+ default: '1'
+ description: >
+ The index at which to begin searching.
+ example: |
+ assert "one two".find("one") == 1
+ assert "one two".find("two") == 5
+ assert "one two".find("three") == none
+ assert "one two".find("o", start=2) == 7
+
Text.from:
short: slice from a starting index
description: >