PHP Regex - 解析大文件
I have a very large files -- some reaching up to 10GB -- that contains mostly structured data (e.g. 99% of it a tab-separated values for each line of text I'm interested in). I need to extract from these files very specific pieces of data that I can easily find via regex. However, my concern is that I'm going to run into all sorts of problems if I try to, say, convert the file into a string and then regex that string.
What's a good strategy for regex parsing very large files?
我有一个非常大的文件 - 有些达到10GB - 主要包含结构化数据(例如99%) 它是我感兴趣的每行文本的制表符分隔值。 我需要从这些文件中提取我可以通过正则表达式轻松找到的非常具体的数据。 但是,我担心的是,如果我尝试将文件转换为字符串,然后将该字符串转换为正则表达式,那么我将遇到各种各样的问题。 p>
什么是好的 正则表达式解析非常大的文件的策略? p> div>
Read the file line by line (fgets) and process it in chunks.