- Should I be using RegularExpressions to do this?
- Possible to structure the results as queryable, IEnumerable, etc.
I have a file, I cannot change how it is generated. I wish to create a parser class to extract all the data. Ideally, I would like to then use this class to open the file and have it return a queryable array type structure I can use.
The data is structured like this:
["Table"] = {
["Text"] = {
["Number"] = {
"Item", --[1]
"Item", --[2]
"Item", --[3]
},
--repeat--
Note that the actual file has line brakes, tab, etc. (\n\t\t)
As you will see the patters I use take this into account
to get different levels.
I have a regular expression that was written for vb6 for this very file but, 1 of the 7 patterns does not work:
@"^\t\[""([\s\S]*?)""] = {([\s\S]*?)^\t},$
This is supposed to group the top most level ["Table"] into their own match. but it returns 0 and it is slow. If I take the $ sign out it just returns all sub nodes too. This is the only thing stopping me from using Regular Expressions to do this.
Another option is just to parse line by line I guess. I am sure I can figure this out given time but I'd like to hear other opinions before I go one way or the other.
Any thoughts?