Forum Discussion
Wildcard Matching 2024 Attempt 2
- Anonymous2 years ago
After days of testing and testing in real life, it looks like my routine works perfectly.
Here is the link again:
https://www.dropbox.com/scl/fi/nw4nwwxa4g99dvbm0vl0s/fnCompareWildcards.pq?rlkey=kw8ze79eytk7uzdpm4miugwdk&dl=1It is several thousand percent faster than RegEx, even with just a few comparisons the difference in runtime is clearly noticeable.
Here is the link to my test file:
https://www.dropbox.com/scl/fi/hnv86prqiewyajra5h0yr/CompareRegEx.xlsm?rlkey=70ge7534tuugp17ottiw2wwya&dl=1If anyone finds an error, you can contact me directly:
andreas(dot)killer(at)gmx(dot)netAndreas.
Hi Gao,
First of all, if you saw my previous post, I deleted it because my conclusions were wrong.
I tried your change (and others with List.Accumulate) and thanks to your idea I realized that this is the wrong part of the code.
The places where the wildcards start a new recursion are correct, the problem is the termination.
I have made some changes here and now it works almost perfectly.
Text: NLTGE2K0ID
Pattern: NLTGE2K*#? Result: true => wrong
Pattern: NLTGE2K*#?? Result: true => correct
Pattern: NLTGE2K*#??? Result: false => correct
I have a lot of randomly generated texts and search patterns, only search patterns that have these characteristics are missing, all others are correct.
If you download my code again and take a look, maybe you will have an idea. My feeling tells me that I have to somehow compare from the end to the front if the search pattern ends with a wildcard.
Andreas.
After days of testing and testing in real life, it looks like my routine works perfectly.
Here is the link again:
https://www.dropbox.com/scl/fi/nw4nwwxa4g99dvbm0vl0s/fnCompareWildcards.pq?rlkey=kw8ze79eytk7uzdpm4miugwdk&dl=1
It is several thousand percent faster than RegEx, even with just a few comparisons the difference in runtime is clearly noticeable.
Here is the link to my test file:
https://www.dropbox.com/scl/fi/hnv86prqiewyajra5h0yr/CompareRegEx.xlsm?rlkey=70ge7534tuugp17ottiw2wwya&dl=1
If anyone finds an error, you can contact me directly:
andreas(dot)killer(at)gmx(dot)net
Andreas.