-
November 15th, 2021, 17:28 #11
Thank you for your comments. In my case, I am reading in txt and outputting xml, so the input elements are always in the same order.
Here is the problem stated more astutely.
A file consists of between 1 and n lines of unique data, always in the same order. Some lines may be missing.
I have n regex expressions to apply to those data lines.
What is the best way to do it?
I thank jharp for giving me the answer. Read in all of the lines of data. Concatenate them to become one line. Apply all of the regex expressions to that one line, one at a time. Done! I was making it overly complicated by trying to determine which regex expression to apply to which line, based on the order of the lines read in, hence the nested if statements.
-
November 15th, 2021, 17:33 #12
Hahaha. The funniest thing just happened. After writing that I went back to reading, and then literally one minute later I read the following:
"Because Lua handles long strings efficiently, a simple technique for writing filters in Lua is to read the whole file into a string, process the string, and then write the string to the output."
That!! That is what I wanted to say. I feel inspired to write code.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks