Accept Merge Request #160: (hyc -> master)
Merge Request: 【修改】msyql关键字 空格换行判断 Created By: @华允传 Accepted By: @华允传 URL: https://g-iswv8783.coding.net/p/education/d/ExamLocalhost/git/merge/160?initial=true
This commit is contained in:
@@ -1504,7 +1504,19 @@ public class IMysqlLocalServiceImpl implements IMysqlLocalService {
|
||||
if (keywordValue != null && !keywordValue.isEmpty() && !matchedKeywords.contains(keywordValue)) {
|
||||
// 使用正则,确保是完整单词(字段)匹配
|
||||
String regex = keywordValue;
|
||||
if (sql.contains(regex)) {
|
||||
// 关键字标准化:连续空白替换成单空格,去掉首尾空格,并转小写
|
||||
String regexKeyword = keywordValue.replaceAll("\\s+", " ").trim().toLowerCase();
|
||||
|
||||
// SQL标准化:连续空白替换成单空格,去掉首尾空格,并转小写
|
||||
String cleanSql = sql.replaceAll("\\s+", " ").trim().toLowerCase();
|
||||
|
||||
// 使用正则匹配单词边界
|
||||
|
||||
String patternStr = "(?i)(^|[^\\w])" + Pattern.quote(regexKeyword) + "($|[^\\w])";
|
||||
Pattern pattern = Pattern.compile(patternStr);
|
||||
Matcher matcher = pattern.matcher(cleanSql);
|
||||
|
||||
if (matcher.find()) {
|
||||
try {
|
||||
totalScoreRate += Integer.parseInt(keyword.getScoreRate());
|
||||
judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "【✅】【关键字】 【" + regex + "】 " );
|
||||
|
Reference in New Issue
Block a user