VB.Net- using an array in a regular expression string
Posted on 2008-11-01
I have a task which involves extracting data from a large number of report files (.txt format). Thanks to the help here, I've been able to get the project rolling using regular expressions in vb.net 2003. I've been able to successfully extract data from the files into 3 of the fields I've tried so far, but I have several other fields that are a bit more complex (from my uninitiated point of view) and had questions in those regards.
Can an array be used in a regular expressions string?
The data that I'm trying to extract is regarding the dates that 'Fieldwork' was conducted. The actual fields I need to populate are 'fieldworkstart' and 'fieldworkend', however if I can just get the general 'fieldwork' data extracted, then I can coax the data further from there.
The dates aren't in a standard format, but they are somewhat consistant in the manner that they were entered. Here are a few examples of the fieldwork and dates occurrences from several of the files.
The fieldwork was performed between August 1 and 5, 2003
The fieldwork was performed on August 12 and 15, 2003
The fieldwork was conducted by John Doe and Jim Public on August 12th and 13th, 2003
The fieldwork was performed during July and August, 2003
The fieldwork was conducted by John Doe and Jim Public between March 16-29, 2004
The fieldwork was conducted in September and October 2003
The fieldwork was performed on July 24, 2003
The fieldwork was conducted on July 28 through August 15, 2003.
The fieldwork was performed on July 24 and 25, (NOTE: NO Year entered in this example)
The fieldwork was performed by John Doe on 07 April 2003
The fieldwork was supervised by John Doe and assisted by Jim Public from April 14 through 29, 2003
The reason I ask if I can use an array in the regular expression is this: Without knowing a better way to proceed, I had thought to create a 'months' array (january, february...december) to do a regular expression search that looked for the month names as part of the match criteria. From the examples above, here is the data that I want to extract to a file (.csv).
fieldwork August 1 and 5, 2003
fieldwork August 12 and 15, 2003
fieldwork September and October 2003
Which I will then (somehow) break down into the proper fields:
fieldworkstart: August 1
fieldworkend: August 5 2003
fieldworkstart: August 12
fieldworkend: August 15 2003
fieldworkend: October 2003
If you need a copy of the working code that I'm using for the other fields (thanks ddrudik!) let me know and I'll post that.
Thanks again all!