Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8914861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:50:01+00:00 2026-06-15T04:50:01+00:00

I have a program that reads each line of file, extracting data according to

  • 0

I have a program that reads each line of file, extracting data according to specific format, defined by a regular expression. Instead of calling Match() multiple times against each line in the file, I could call Match() against the entire contents of the file. Which is a more efficient solution?

The latter choice would require the RegexOptions.Multiline option.

Update:

The file is specified by the end-user so it could be large (~37000 lines, ~2MB). It is not necessary for every line to contain a valid entry.

The regular expression I’m using is ^\s*(OPTL_\w*)\s*=>\s*(\d+)\s*$. For example, this would match the a line consisting of the text OPTL_Example => 123, but would not match a line consisting of the text FooBar => 999.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:50:02+00:00Added an answer on June 15, 2026 at 4:50 am

    So depends on if you are optimizing for speed or stability.

    If this is an end user app and don’t have control of file size or memory then I would take the safe route and read line by line to protect memory. Clearly build the regex outside the loop so you are just calling .Match in the loop. ReadLine is pretty fast.

    Could set up some parallel processing so it is reading the next line while it is performing the parse. But that simple regex would be so fast not sure it would be faster. Line at a time or entire file the disk IO to read the file is most likely the slowest operation.

    If this is a server app with limited distribution and speed it critical then read it all in.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that reads data from a file line-by-line. I would like
I have a java program that reads each line in a file text and
I have a small program that reads in a file and processes the data
I have a program that reads a huge text file (line by line) and
I am working on a Java program that reads a text file line-by-line, each
I have a program that reads from a file that grabs 4 bytes from
I have a program that reads input from a file. I am trying to
I have a program that reads a file, treat it and put the results
I have a program that reads one image file, makes some changes on that
I want to have a program that reads metadata from an MP3 file. My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.