Update string doc: index can be negative (#1198)

This commit is contained in:
Leedehai 2023-05-19 08:41:58 -04:00 committed by GitHub
parent f9ab828e29
commit 8d4f9304c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -219,7 +219,8 @@ Typst provides utility methods for string manipulation. Many of these methods
either a string or a [regular expression]($func/regex). This makes the methods
quite versatile.
All lengths and indices are expressed in terms of UTF-8 bytes.
All lengths and indices are expressed in terms of UTF-8 characters. Indices are
zero-based and negative indices wrap around to the end of the string.
### Example
```example

View File

@ -24,6 +24,8 @@
// Test the `at` method.
#test("Hello".at(1), "e")
#test("Hello".at(4), "o")
#test("Hello".at(-1), "o")
#test("Hello".at(-2), "l")
#test("Hey: 🏳️‍🌈 there!".at(5), "🏳️‍🌈")
---