-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/support query with column name (#458)
* query compare configuration by names * fix regex problem of special chars * update version
- Loading branch information
Showing
33 changed files
with
424 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
arex-web-common/src/main/java/com/arextest/web/common/RegexUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.arextest.web.common; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* @author b_yu | ||
* @since 2024/12/20 | ||
*/ | ||
|
||
public class RegexUtils { | ||
|
||
private static final Set<Character> SPECIAL_CHARS = new HashSet<>(); | ||
|
||
static { | ||
char[] specialCharsArray = {'.', '\\', '+', '*', '?', '[', '^', ']', '$', '(', ')', '{', '}', | ||
'=', '!', '<', '>', '|', ':', '-'}; | ||
for (char c : specialCharsArray) { | ||
SPECIAL_CHARS.add(c); | ||
} | ||
} | ||
|
||
public static String getRegexForFuzzySearch(String keyword) { | ||
if (keyword == null || keyword.isEmpty()) { | ||
return keyword; | ||
} | ||
return ".*?" + escapeSpecialChars(keyword) + ".*"; | ||
} | ||
|
||
private static String escapeSpecialChars(String keyword) { | ||
if (keyword == null || keyword.isEmpty()) { | ||
return keyword; | ||
} | ||
StringBuilder escapedKeyword = new StringBuilder(); | ||
for (char c : keyword.toCharArray()) { | ||
if (SPECIAL_CHARS.contains(c)) { | ||
escapedKeyword.append('\\'); | ||
} | ||
escapedKeyword.append(c); | ||
} | ||
return escapedKeyword.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.