Hey all, my first thread in the Developer forum. I'm basically looking for some feedback.
I'm not looking for a search algorithm, mind. Just a parsing algorithm to handle the search terms. So far I've come up with four basic types of searches (or three if you don't count SoundEx searches):
"literal" -excluded [SoundEx] contains
That is, anything in double-quotes looks for an exact match; anything preceded by a hyphen cannot be matched; anything contained within brackets is matched using SoundEx codes (the bracket convention is specific to my application and is not as far as I know a standard search parser convention); and anything else--split at whitespace--is generally matched as a basic substring.
My idea is to break a search string into an associative array that is sort of bitmasked. Each binary key would represent a type of search, a la
Code:
Public Enum stSearchType
stLiteral = 1
stContains = 2
stExcludes = 4
stSoundEx = 8
End Enum
So that for array
SearchArray(8, n),
Code:
SearchArray(1, n) ' all the search criteria falling within quote wrappers
SearchArray(2, n) ' all the unspecified search criteria
SearchArray(4, n) ' all the search criteria matching a "* -?*" pattern
SearchArray(8, n) ' all the search criteria falling within brackets
I thought I might go through the input string in chunks, but the more I think about it, the more I believe I should go one character at a time. VBA is worth about diddly when it comes to regular expressions, and its String object class doesn't have robust methods. Therefore, in order to match opening code characters (i.e.,
",
[, and
Like "* -?*") against their closing character counterpart, I think I need to process the characters one at a time. That's what I'm currently doing, but it seems like a mediocre algorithm at best.
Does anyone have other suggestions, or experience in trying to emulate this kind of functionality? Unfortunately the language has to be VBA; if you know of similar logic, I'd be interested because I might be able to port it.
Thanks,
chris.