EscapeSequence class

Describes one escape sequence of a format string, the text to look for and what replaces it, and applies it to a string.

An escape sequence is either plain or ASCII:

  • A plain sequence replaces every occurrence of a fixed text with a fixed replacement. \n and \t are plain.
  • An ASCII sequence is a regular expression with one capture group. The group captures the digits of a character code, which are read in octal or hexadecimal (AsciiEscapeBase), and each match is replaced with the character that has that code. \xHH and \ooo are ASCII.

EscapeSequence is predeclared. Create is called on the class name and returns a configured instance, and Execute applies the sequence to a string. StringHelper creates the ten sequences that StringFormat expands; the package overview lists them.

Dim esc As EscapeSequence
Set esc = EscapeSequence.Create("\z", "ZZ")

Dim text As String
text = "a\zb"
esc.Execute text
Debug.Print text  ' aZZb

Note

Self and the four property setters (AsciiBase, EscapeString, IsAsciiCharacter and ReplacementString with Let) are declared Friend, for Create to use. A project that references the package can call them too (checked on BETA 1005), so the properties of an instance can be changed after it is created.

Properties

  • AsciiBase – returns the number base of an ASCII sequence
  • EscapeString – returns the text or the pattern to look for
  • IsAsciiCharacter – returns whether the sequence is an ASCII sequence
  • ReplacementString – returns the text that replaces a plain sequence
  • Self – returns the object itself

Methods

  • Create – creates an escape sequence
  • Execute – applies the sequence to a string

See Also