Skip to content

Commit 6a4f346

Browse files
committed
fix: move ST into a variable
1 parent 2ae99de commit 6a4f346

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
export default function ansiRegex({onlyFirst = false} = {}) {
2+
// Valid string terminator sequences are BEL, ESC\, and 0x9c
3+
const ST = '(?:\\u0007|\\u001B\\u005C|\\u009C)';
24
const pattern = [
3-
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))',
5+
`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
46
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))'
57
].join('|');
68

0 commit comments

Comments
 (0)