In our organization we have various business units that organize their data in different ways. The folder structure can vary, but they abide by business unit practices when making backups etc.
I am to make a scraper that locates backups and copies them. I have found a general way to describe the business unit specific way of making backups. I do not wish to search the whole directory structure because it may be massive.
/X A a B a C a
Here for instance, in order to locate all the lower case "a", I can say that the criteria is a list of strings
The X will satisfy the first asterisk. The A/B/C subfolders will satisfy the second asterisk and the lower case a's will satisfy the lower case a criteria. Already, we see a potential for the two "" to be represented as "" and a multiplier modifier.
All well and good. In C#, this is easy. The DirectoryInfo class has the GetDirectories method which performs a scan with a searchpattern.
However, what if the structure is staggered? What if I would like to list the criteria as follows?
Pattern="*" MaxRepetitions=3 MinRepetitions=1 Pattern="a" MaxRepetitions=1 MinRepetitions=1
The code becomes messy quick. For instance "a" will also be satisfied by "*" criteria, so the engine may not be "sure" which criteria is being exhausted and therefore must test multiple criteria on next pass. I assume regex has solved this problem because it runs so fast on large strings and still manages to return without duplicates.
Are there any pointers? Is there any theory behind how to preserve a context (visitor state), assuming this is the visitor pattern.