Is there a fast way to parse through a large file with regex?

前端 未结 4 1562
面向向阳花
面向向阳花 2021-02-20 17:49

Problem: Very very, large file I need to parse line by line to get 3 values from each line. Everything works but it takes a long time to parse through the whole file. Is it poss

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-20 18:28

    Right now, you recreate your Regex each time you call GetRateLine, which occurs every time you read a line.

    If you create a Regex instance once in advance, and then use the non-static Match method, you will save on regex compilation time, which could potentially give you a speed gain.

    That being said, it will likely not take you from minutes to seconds...

提交回复
热议问题