I need the pseudocode for an algorithm that matches strings based on a pattern based on DOS wildcards:
? matches any one character.
* matches zero or more characters, as many characters as possible.
any other character matches that character.
The pattern must match the entire string perfectly or it is a failure.
The * is the thing that is giving me the most trouble, by the way.
Comments
:
Ok, I can't write it in paseudo code, but I can give you the idea:
try splitting your query string to sections, when the * is the seperator:
"A*B*CD" -> ["A","B","CD"]
the compare each of the sections with the data string, checking in each compiration that the index of the mach (if found) is bigger then the index of the mach of the previous section.
"AdfsBtfgCD"
index of "A" is 1.
index of "B" is 5 - bigger then 1.
index of "CD" is 9 - bigger then 5.
string mach.
I hope I'm clear....