Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
17th April 2023, 10:32 | #1 | Link |
German doom9/Gleitz SuMo
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 7,039
|
How to strip extended XTerm ANSI Escape sequences with RegEx?
In general, an ANSI Escape sequence is made of
These strings could be filtered with a regular expression substitution for e.g. sed like: Code:
s/\x1b\[[0-9;]*[a-zA-Z]//g I tried several ways to substitute the \[ with a list of \[, \] and \(, but I can't get it working correctly... If you want to test a solution you would like to recommend, here is a small sample. __ PS: Some progress ... I could combine patterns starting with ESC and ([ or () using Code:
s/\x1b[[(][0-9;]*[a-zA-Z]//g __ PPS: I believe I got it. The pipe | needs to be escaped to be recognised as logical OR inside the sed parameter, but only in the live editor; in a shell script it doesn't. Code:
s/\x1b[[(][0-9;]*[a-zA-Z]|\x1b\][0-9];//g Last edited by LigH; 17th April 2023 at 12:18. |
Thread Tools | Search this Thread |
Display Modes | |
|
|