From 4914bb9003e07b574a221eb65474b60020b5b106 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sat, 26 Aug 2017 19:59:26 -0600 Subject: [PATCH] Add getFullMatchRegExp(): This will be used elsewhere eventually --- core/ansi_term.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/ansi_term.js b/core/ansi_term.js index 33981f02..dd5ef264 100644 --- a/core/ansi_term.js +++ b/core/ansi_term.js @@ -31,6 +31,7 @@ const miscUtil = require('./misc_util.js'); const assert = require('assert'); const _ = require('lodash'); +exports.getFullMatchRegExp = getFullMatchRegExp; exports.getFGColorValue = getFGColorValue; exports.getBGColorValue = getBGColorValue; exports.sgr = sgr; @@ -172,6 +173,12 @@ const SGRValues = { whiteBG : 47, }; +function getFullMatchRegExp(flags = 'g') { + // :TODO: expand this a bit - see strip-ansi/etc. + // :TODO: \u009b ? + return new RegExp(/[\u001b][[()#;?]*([0-9]{1,4}(?:;[0-9]{0,4})*)?([0-9A-ORZcf-npqrsuy=><])/, flags); // eslint-disable-line no-control-regex +} + function getFGColorValue(name) { return SGRValues[name]; }