编排添加解析路径功能

This commit is contained in:
fofolee
2025-01-05 13:08:22 +08:00
parent 00ddba20ec
commit 923fc9e4de
16 changed files with 684 additions and 34 deletions

View File

@@ -0,0 +1,25 @@
const string = {
// 字符串反转
reverseString: function (text) {
return text.split("").reverse().join("");
},
// 字符串替换
replaceString: function (text, oldStr, newStr) {
return text.replaceAll(oldStr, newStr);
},
// 字符串截取
substring: function (text, start, end) {
return text.substring(start, end);
},
// 正则处理
regexTransform: function (text, regex, replace) {
try {
if (replace === undefined) return text.match(regex);
return text.replace(regex, replace);
} catch (e) {
throw "正则表达式格式错误";
}
},
};
module.exports = string;