Crate escape_string

Source
Expand description

Efficiently split lines by whitespace, while handling the backslash escape sequences in Rust-like string format.

For example, if you had a string like:

  One\ two three\ four

Naïve splitting on whitespace would produce four outputs:

  • One\
  • two
  • three\
  • four

This crate will instead produce two strings:

  • One two
  • three four

This crate also handles special escape sequences like “\n”, which represents a newline. Specifically, the escape sequences are:

  • \a
  • \b
  • \t
  • \n
  • \v
  • \f
  • \r
  • \\

If the backslash character is found, but the successive character is not special, then the backslash is disregarded and the successive character is included verbatim.

Functions§

escape
Converts text with all the special characters escape with a backslash
split
Produce all the words as a vector
split_one
Split some text by unescaped whitespace.
split_one_bytes
Splits once