Improve `WildCardMatch` function to handle edge cases in the `regex` package
Description
The current implementation of the WildCardMatch function in the regex package works well for many scenarios, but there are several edge cases that need to be addressed to ensure robustness. Below are the identified edge cases:
-
Empty Strings:
- Both
patternandkeyare empty. -
patternis empty, butkeyis not. -
keyis empty, butpatternis not.
- Both
-
Only Wildcards:
-
patternconsists only of `` characters. -
patternconsists only of?characters.
-
Examples
-
pattern = "",key = ""(should returntrue). -
pattern = "*",key = "anything"(should returntrue).
Suggested Improvements
- Add checks and logic to handle the above edge cases.
- Write unit tests to cover these scenarios.
@iamanjali1003 can you please add details around which repo and file these changes are for? Also add few examples by execution for reference.
@lucifercr07 I am referring to the code found here: https://github.com/DiceDB/dice/blob/master/internal/regex/regex.go, specifically the WildCardMatch function. We are using this function here: https://github.com/DiceDB/dice/blob/master/internal/sql/executor.go#L467.
cc: @JyotinderSingh for reference.
@lucifercr07 / @iamanjali1003 - can this task be assigned to me