diff --git a/docs/src/reference/types.md b/docs/src/reference/types.md index cc30ef1f4..a5741337a 100644 --- a/docs/src/reference/types.md +++ b/docs/src/reference/types.md @@ -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 diff --git a/tests/typ/compiler/string.typ b/tests/typ/compiler/string.typ index 0bc3a9be5..ddd0f7fff 100644 --- a/tests/typ/compiler/string.typ +++ b/tests/typ/compiler/string.typ @@ -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), "🏳️‍🌈") ---