22 June 2007

Regular Expressions and Like Statement

There is a new requirement for this application to be able to parse numbers embedded in file names. One issue is that C# DataTables do not allow for complex, regular expression searches in fields. That means that I will have to create on the fly regular expressions, query my local files database and then run a post process on the remaining records to see if more than one file comes up.

The query process will be as follows:

1. When loading hooks into the table, replace [snam] with the SNAM
2. Create a boolean value in the table to indicate if the hook has a [n] wildcard in it
3. Query the files table with the first [n] in the hook as the */% wildcard
4. Pass the records to a function with the hook. The function returns the number of records found.
5. Build a regular expression based on the string. Replace '[n]' with '[0-9]+'
6. Cycle through the array. If a match is found, increment the match.
7. Return the array back to the calling function for processing.