18 lines
553 B
JavaScript
18 lines
553 B
JavaScript
function e(e) {
|
|
return typeof e == `string` && /-L\s*$/.test(e);
|
|
}
|
|
function t(e) {
|
|
return typeof e == `string` ? e.replace(/-L\s*$/, ``).trim() : ``;
|
|
}
|
|
function n(n, r) {
|
|
if (!n) return ``;
|
|
let i = [...new Set(r.filter((t) => e(t)).map((e) => e.trim()))].sort(
|
|
(e, t) => t.length - e.length,
|
|
);
|
|
if (!i.length) return n;
|
|
let a = i.map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, `\\$&`)).join(`|`),
|
|
o = RegExp(`(?<![A-Za-z0-9_-])(?:${a})(?![A-Za-z0-9_-])`, `g`);
|
|
return n.replace(o, (e) => t(e));
|
|
}
|
|
export { t as n, n as r, e as t };
|