stringman
Version:
Stringman does string manipulation and other string operations. Do anything from lightening color codes to swapping email address in a string!
37 lines (36 loc) • 716 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.common = void 0;
function isValid(str, exp) {
if (typeof str !== 'string') {
return false;
}
return exp.test(str);
}
function swap(str, str2, exp) {
if (str && str2 && exp) {
return str.replace(exp, str2);
}
else {
return '';
}
}
function remove(str, exp) {
if (typeof str !== 'string') {
return str;
}
return str.replace(exp, '').trim();
}
function retrieve(str, exp) {
if (typeof str !== 'string') {
return [];
}
return str.match(exp) || [];
}
const common = {
isValid,
remove,
retrieve,
swap
};
exports.common = common;
;