Add getFullMatchRegExp(): This will be used elsewhere eventually

This commit is contained in:
Bryan Ashby 2017-08-26 19:59:26 -06:00
parent c58f9a6510
commit 4914bb9003
1 changed files with 7 additions and 0 deletions

View File

@ -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];
}