How do I re.search or re.match on a whole file without reading it all into memory?

前端 未结 9 1287
不知归路
不知归路 2020-12-01 01:14

I want to be able to run a regular expression on an entire file, but I\'d like to be able to not have to read the whole file into memory at once as I may be working with rat

9条回答
  •  眼角桃花
    2020-12-01 01:29

    For single line patterns you can iterate over the lines of the file, but for multi-line patterns, You will have to read all (or part, but that'll be hard to keep track of) of the file into memory.

提交回复
热议问题