Module util

Source
Expand description

A collection of helper functions that process literal conversions.

§delimit and undelimit

provide text convertion between delimited and undelimited literals.

§Others

unescape_from_bytes, and unescape removes any escape character / that is prefixed to delimiter sequences in the regular expression literals. escape and escape_into_bytes prepend / to all delimiters in input texts.

Functions§

delimit
create a delimited regular expression with the given delimiter string.
delimit_many
testing: creating a string list of delimited regular expressions
escape
Use escape function for escaping any delimiter sequence in regular expression text.
escape_into_bytes
Use escape_into_bytes function for escaping delimiter sequences and converting regular expression text into bytes
infer_char_size
infer character length from 1st byte. reference: UTF-8
offset_ws
check if there is any leading whitespace from a given start byte index and return the offset between start and non-whitespace character
undelimit
Strip off the enclosing delimiter pair and unescape delimiters from the input content. undelimit is the reversed function of delimit .
unescape
Convert any escaped delimiter sequence in the input string slices. Use unescape function for removing the escape character ’' from each escaped delimiter sequences in input string slices. This returns two variants, a Cow wrapped string if succeeds, and an error in String type if fails. unescape is the reversed function of escape .
unescape_from_bytes
Use unescape_from_bytes function for removing the escape character ’' from each escaped delimiter sequence in input bytes. This returns two variants: a Cow typed string if succeeds, and an error if fails.