stringext
luau
local stringext = require("@std/stringext")WARNING
These APIs are still open to future evolution. In new major versions, they may change in backwards incompatible ways.
Summary
| Entry | Description |
|---|---|
| count | Counts the number of occurrences of pattern in str, optionally restricted to the range [startPos, endPos]. |
| hasPrefix | Returns true if str begins with prefix. |
| hasSuffix | Returns true if str ends with suffix. |
| removePrefix | Returns str with prefix removed from the front. If str does not start with prefix, returns str unchanged. |
| removeSuffix | Returns str with suffix removed from the end. If str does not end with suffix, returns str unchanged. |
| trim | Returns str with leading and trailing whitespace removed. |
Functions and Properties
stringext.count
Counts the number of occurrences of pattern in str, optionally restricted to the range [startPos, endPos].
luau
(str: string, pattern: string, startPos: number?, endPos: number?) -> numberstringext.hasPrefix
Returns true if str begins with prefix.
luau
(str: string, prefix: string) -> booleanstringext.hasSuffix
Returns true if str ends with suffix.
luau
(str: string, suffix: string) -> booleanstringext.removePrefix
Returns str with prefix removed from the front. If str does not start with prefix, returns str unchanged.
luau
(str: string, prefix: string) -> stringstringext.removeSuffix
Returns str with suffix removed from the end. If str does not end with suffix, returns str unchanged.
luau
(str: string, suffix: string) -> stringstringext.trim
Returns str with leading and trailing whitespace removed.
luau
(str: string) -> string