Import with #import "std/text_tools".

TextFind :: (text: string, needle: string, from: s64) -> s64

The first index of NEEDLE in TEXT at or after FROM, or -1.

TextFindLast :: (text: string, needle: string) -> s64

The last index of NEEDLE in TEXT, or -1.

TextContains :: (text: string, needle: string) -> bool
TextHasPrefix :: (text: string, prefix: string) -> bool
TextHasSuffix :: (text: string, suffix: string) -> bool
TextIsSpace :: (byte: u8) -> bool
TextTrim :: (text: string) -> string

TEXT without leading and trailing ASCII whitespace.

TextTrimEnd :: (text: string) -> string

TEXT without trailing ASCII whitespace.

TextSplit :: (text: string, separator: string) -> Vec(string)

Every piece of TEXT between SEPARATORs, empty pieces included, as Python's str.split(separator) gives them.

TextLines :: (text: string) -> Vec(string)

The lines of TEXT without their line endings (\n, \r\n or \r); a final line ending adds no empty line.

TextReplace :: (text: string, old: string, new: string) -> Text

TEXT with every OLD replaced by NEW, left to right.

TextJoin :: (parts: []string, separator: string) -> Text
TextLower :: (text: string) -> Text

TEXT with ASCII letters in lower case.

TextIsDecimal :: (text: string) -> bool

Whether TEXT is one or more decimal digits.

TextIsLowerHex :: (text: string) -> bool

Whether TEXT is one or more lowercase hexadecimal digits.

TextOnly :: (text: string, allowed: string) -> bool

Whether every byte of TEXT is one of ALLOWED's bytes; empty TEXT is not.

TextInteger :: (text: string) -> (s64, bool)

The whole of TEXT as a decimal integer with an optional sign.

TextHexDigit :: (byte: u8) -> s32

The value of a hexadecimal digit, or -1.

TextHexDecodeInto :: (value: string, output: *Vec(u8), max_bytes: s64) -> bool

Decodes VALUE's uppercase or lowercase hexadecimal bytes and appends them to OUTPUT. MAX_BYTES bounds the bytes this call appends; false leaves OUTPUT unchanged on any failure, including an odd length, an invalid digit, an exceeded limit, or an allocation failure.

TextHex :: (bytes: []u8) -> Text

BYTES as lowercase hexadecimal.

Source ↗ · All modules