(see the updates I've made to the OP)
Sure, the ugly code produces the output I want -- that the supplied category (albeit, with an additional trailing dot), which comes from the list of possible categories, does match the category in the record (again, doctored with a trailing dot), when considering the 'level of matching' required.
Although it's not my current application, perhaps think of the number of postings in the Usenet hierarchies. The data might be:
comp.lang.c,100
comp.lang.beta,23
comp.lang.java.help,123
comp.object,12
alt.3d,12
alt.animals.llama,1423
...
The types of question I'm looking to answer:
"How many postings are there in the 'comp' hierarchy and below?"
For this question, we can say:
Matches: comp, comp.lang, comp.lang.c... (the group names all start with 'comp')
Do not Match: alt, alt.3d, alt.animals.llama... (the group names do not start with 'comp')
"How many postings are there in the 'alt.*' hierarchy and below?"
For this question, we can say:
Matches: alt.3d, alt.animals.llama... (the group names all start with 'alt.{something}' and {something} is non-null)
Do not match: alt, comp, comp.lang.c... (the group names do NOT start with 'alt.{something}' and {something} is non-null)
Conceptually, it's such a simple thing: "Does RECORD CAT start with the TEST string?" ...
TEST RECORD MATCHES?
comp comp.lang Yes
comp comp Yes
comp comp.hw No
comp.lang comp No
comp.lang comp.lang Yes
comp.lang comp.lang.c Yes
comp.lang comp.lang.c++ Yes
comp.lang alt No
comp.lang alt.test No
This is why I was thinking there must be a simple regex thing to say "give me the first 2 items from the category string" (using parentheses and a dot or end-of-string as the separator - 'comp.lang') and I'll compare that to the start of the record string (in a simple regex: /^$rec_string\.*$/ or something).....
...shaking his head in bewilderment...
|