strip_ansi_escapes
This page explains how to use the strip_ansi_escapes function in APL.
Use the strip_ansi_escapes function in APL to remove ANSI escape sequences from strings. ANSI escape codes are special character sequences used in terminal output to control text formatting, colors, and cursor positioning. When analyzing logs or terminal output, these codes can interfere with text processing, search operations, and data analysis.
You use strip_ansi_escapes when you need to clean up terminal output, colorized logs, or any text that contains ANSI formatting codes. This is particularly useful when ingesting logs from command-line tools, CI/CD pipelines, container logs, or any system that outputs colored or formatted terminal text.
Usage
Syntax
Parameters
| Name | Type | Description |
|---|---|---|
text | string | The string containing ANSI escape sequences that you want to remove. |
Returns
A string with all ANSI escape sequences removed, leaving only the plain text content.
List of related functions
- trim: Use
trimto remove leading and trailing characters. Usestrip_ansi_escapesspecifically for removing ANSI escape sequences anywhere in the string. - replace_regex: Use
replace_regexfor custom pattern-based replacements. Usestrip_ansi_escapesas a specialized, optimized solution for ANSI codes. - trim_space: Use
trim_spaceto remove whitespace. Usestrip_ansi_escapesto clean formatting codes. - extract: Use
extractto pull specific patterns from text. Usestrip_ansi_escapesto clean the text before extraction for better pattern matching.