Explorar el Código

Merge pull request #2142 from visuddhinanda/agile

用正则表达式判断拼写是否匹配
visuddhinanda hace 1 año
padre
commit
d7b5e09fc6
Se han modificado 1 ficheros con 9 adiciones y 4 borrados
  1. 9 4
      dashboard/src/components/template/Wbw/WbwDetailRelation.tsx

+ 9 - 4
dashboard/src/components/template/Wbw/WbwDetailRelation.tsx

@@ -147,10 +147,15 @@ const WbwDetailRelationWidget = ({
           caseMatch = false;
         }
       }
-      if (value.from?.spell) {
-        if (data.real.value !== value.from?.spell) {
-          spellMatch = false;
-        }
+      if (value.from?.spell && data.real.value) {
+        // 假设你有一个字符串表示的正则表达式
+        const regexString = value.from?.spell.replaceAll("*", "\\w");
+
+        // 创建正则表达式对象
+        const regex = new RegExp(regexString);
+
+        // 使用正则表达式
+        spellMatch = regex.test(data.real.value);
       }
 
       console.debug("relation match", value, caseMatch, spellMatch);