# EscapeSequence class
{: .no_toc }

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**](/tB/Packages/Contributed/Fmt/AsciiEscapeBase.md)), and each match is replaced with the character that has that code. `\xHH` and `\ooo` are ASCII.

**EscapeSequence** is predeclared. [**Create**](/tB/Packages/Contributed/Fmt/EscapeSequence/Create.md) is called on the class name and returns a configured instance, and [**Execute**](/tB/Packages/Contributed/Fmt/EscapeSequence/Execute.md) applies the sequence to a string. [**StringHelper**](/tB/Packages/Contributed/Fmt/StringHelper.md) creates the ten sequences that **StringFormat** expands; the [package overview](/tB/Packages/Contributed/Fmt/index.md#escape-sequences) lists them.

```tb check_build check_run
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] BETA 1042
> [**Self**](/tB/Packages/Contributed/Fmt/EscapeSequence/Self.md) and the four property setters ([**AsciiBase**](/tB/Packages/Contributed/Fmt/EscapeSequence/AsciiBase.md), [**EscapeString**](/tB/Packages/Contributed/Fmt/EscapeSequence/EscapeString.md), [**IsAsciiCharacter**](/tB/Packages/Contributed/Fmt/EscapeSequence/IsAsciiCharacter.md) and [**ReplacementString**](/tB/Packages/Contributed/Fmt/EscapeSequence/ReplacementString.md) with **Let**) are declared **Friend**, for [**Create**](/tB/Packages/Contributed/Fmt/EscapeSequence/Create.md) to use. A project that references the package can call them too, so the properties of an instance can be changed after it is created.

## Properties

- [AsciiBase](/tB/Packages/Contributed/Fmt/EscapeSequence/AsciiBase.md) -- returns the number base of an ASCII sequence
- [EscapeString](/tB/Packages/Contributed/Fmt/EscapeSequence/EscapeString.md) -- returns the text or the pattern to look for
- [IsAsciiCharacter](/tB/Packages/Contributed/Fmt/EscapeSequence/IsAsciiCharacter.md) -- returns whether the sequence is an ASCII sequence
- [ReplacementString](/tB/Packages/Contributed/Fmt/EscapeSequence/ReplacementString.md) -- returns the text that replaces a plain sequence
- [Self](/tB/Packages/Contributed/Fmt/EscapeSequence/Self.md) -- returns the object itself

## Methods

- [Create](/tB/Packages/Contributed/Fmt/EscapeSequence/Create.md) -- creates an escape sequence
- [Execute](/tB/Packages/Contributed/Fmt/EscapeSequence/Execute.md) -- applies the sequence to a string

## See Also

- [AsciiEscapeBase](/tB/Packages/Contributed/Fmt/AsciiEscapeBase.md) enumeration -- the number bases
- [StringHelper](/tB/Packages/Contributed/Fmt/StringHelper.md) class -- creates and applies the sequences
- [FormerEscapeSequence](/tB/Packages/Contributed/Fmt/FormerEscapeSequence/index.md) class -- a plain sequence without an **Execute** method, unused by the package
- [Fmt package](/tB/Packages/Contributed/Fmt/index.md) -- overview, with the table of escape sequences
