Skip to content

Commit 3742eb6

Browse files
committed
util: improve ansi escape code regex
1 parent f277d75 commit 3742eb6

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/internal/util/inspect.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ const meta = [
222222
// License: MIT, authors: @sindresorhus, Qix-, arjunmehta and LitoMore
223223
// Matches all ansi escape code sequences in a string
224224
const ansiPattern = '[\\u001B\\u009B][[\\]()#;?]*' +
225-
'(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)' +
225+
'(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*' +
226+
'|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)' +
226227
'|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))';
227228
const ansi = new RegExp(ansiPattern, 'g');
228229

0 commit comments

Comments
 (0)