Regular Expressions 101

Strip ANSI CSI

Open Workspace
  • JavaScript
  • Match
0

Regular Expression

/
((?:\\033|\e|\\x1B|\\x1b){1}(?:\[(?:=|\?|[0-9]*)[0-9]*[a-gA-GnmsuJKhlHL]{0,1}(?:(?:\;[0-9]*)*m){0,1}))
/
g

Description

Use control_sequence_filter group to find and remove ANSI CSI codes. Not tested thoroughly. Only for the task that was necessary for me

Submitted by Leonards Elksnis