AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
> type:1:首字母大写2:首字母小写3:大小写转换4:全部大写5:全部小写 ``` export const changeCase = (str, type) => { type = type || 4 switch (type) { case 1: return str.replace(/\b\w+\b/g, function (word) { return word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase(); }); case 2: return str.replace(/\b\w+\b/g, function (word) { return word.substring(0, 1).toLowerCase() + word.substring(1).toUpperCase(); }); case 3: return str.split('').map(function (word) { if (/[a-z]/.test(word)) { return word.toUpperCase(); } else { return word.toLowerCase() } }).join('') case 4: return str.toUpperCase(); case 5: return str.toLowerCase(); default: return str; } } ```