5E Product Walkthrough Playlist
Page 2 of 2 First 12
  1. #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.

  2. #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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
DICE PACKS BUNDLE

Log in

Log in