Add Ability to Import All File Areas at Once #271

* Simple wildcard support for area tags param
This commit is contained in:
Bryan Ashby 2020-05-07 20:02:12 -06:00
parent d6dce82a92
commit 14f7ca9dcc
No known key found for this signature in database
GPG key ID: B49EB437951D2542
4 changed files with 41 additions and 3 deletions

View file

@ -29,6 +29,7 @@ exports.isAnsi = isAnsi;
exports.isAnsiLine = isAnsiLine;
exports.isFormattedLine = isFormattedLine;
exports.splitTextAtTerms = splitTextAtTerms;
exports.wildcardMatch = wildcardMatch;
// :TODO: create Unicode version of this
const VOWELS = [
@ -474,3 +475,8 @@ function isAnsi(input) {
function splitTextAtTerms(s) {
return s.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/g);
}
function wildcardMatch(input, rule) {
const escapeRegex = (s) => s.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
return new RegExp("^" + rule.split("*").map(escapeRegex).join(".*") + "$").test(input);
}