diff --git a/src/App.vue b/src/App.vue index 32ba27b..940b96e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,169 +1,160 @@ diff --git a/src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue b/src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue index 60423dc..0392bfe 100644 --- a/src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue +++ b/src/views/basic/askTestQuestion/components/wrongQuestionDialog.vue @@ -603,24 +603,31 @@ export default { }, processString(input) { // 正则表达式: - const regexs = [/[0-9]+[.)]/, /(\d+分)/, /^(\d{1,3})/]; + // const regexs = [/[0-9]+[.)]/, /(\d+分)/, /^(\d{1,3})/]; - // 使用正则表达式匹配并处理输入字符串 - for (const regex of regexs) { - const match = input.match(regex); - if (match) { - if (regex === regexs[2]) { - // 如果匹配第三条规则,使用substring截取返回结果的长度加1 - const matchLength = match[0].length; - return input.substring(matchLength + 1).trim(); - } else { - // 如果匹配第一条或第二条规则,替换匹配的部分 - input = input.replace(regex, ""); - } - } + // // 使用正则表达式匹配并处理输入字符串 + // for (const regex of regexs) { + // const match = input.match(regex); + // if (match) { + // if (regex === regexs[2]) { + // // 如果匹配第三条规则,使用substring截取返回结果的长度加1 + // const matchLength = match[0].length; + // return input.substring(matchLength + 1).trim(); + // } else { + // // 如果匹配第一条或第二条规则,替换匹配的部分 + // input = input.replace(regex, ""); + // } + // } + // } + const match = input.match(/^(\d{1,3})/); + if (match) { + const matchLength = match[0].length; + input = input.substring(matchLength + 1).trim(); } - - return input; + // 使用正则表达式匹配并处理输入字符串 + input = input.replace(/[0-9]+[.)]/, ""); + input = input.replace(/(\d+(\.\d+)?分)/g, ""); + return input.trim(); }, // 接受两个参数,返回需要删除的数据以及需要添加的数据 diff --git a/src/views/basic/askTestQuestion/wrongQuestion.vue b/src/views/basic/askTestQuestion/wrongQuestion.vue index 17be1cf..2d843f5 100644 --- a/src/views/basic/askTestQuestion/wrongQuestion.vue +++ b/src/views/basic/askTestQuestion/wrongQuestion.vue @@ -55,7 +55,7 @@ - 时间: + 时间: - 题型: - 筛选错题 @@ -622,25 +621,15 @@ export default { this.getClassList(); }, processString(input) { - // 正则表达式: - const regexs = [/[0-9]+[.)]/, /(\d+分)/, /^(\d{1,3})/]; - - // 使用正则表达式匹配并处理输入字符串 - for (const regex of regexs) { - const match = input.match(regex); - if (match) { - if (regex === regexs[2]) { - // 如果匹配第三条规则,使用substring截取返回结果的长度加1 - const matchLength = match[0].length; - return input.substring(matchLength + 1).trim(); - } else { - // 如果匹配第一条或第二条规则,替换匹配的部分 - input = input.replace(regex, ""); - } - } + const match = input.match(/^(\d{1,3})/); + if (match) { + const matchLength = match[0].length; + input = input.substring(matchLength + 1).trim(); } - - return input; + // 使用正则表达式匹配并处理输入字符串 + input = input.replace(/[0-9]+[.)]/, ""); + input = input.replace(/(\d+(\.\d+)?分)/g, ""); + return input.trim(); }, // 获取ref