Module regex_literal::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§

  • create a delimited regular expression with the given delimiter string.
  • testing: creating a string list of delimited regular expressions
  • Use escape function for escaping any delimiter sequence in regular expression text.
  • Use escape_into_bytes function for escaping delimiter sequences and converting regular expression text into bytes
  • infer character length from 1st byte. reference: UTF-8
  • check if there is any leading whitespace from a given start byte index and return the offset between start and non-whitespace character
  • Strip off the enclosing delimiter pair and unescape delimiters from the input content. undelimit is the reversed function of delimit .
  • 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 .
  • 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.