Preg_match and long lines

This is the preg_match that I am trying to use to search for specific text in a text file.

if (preg_match($regexp,$textFile,$result) > 0) {
    echo "Found ".$result[0];
} else {
    echo "Not found";
}

However, the result is always Foundand nothing more. The result array is empty. Now I read that preg_match cannot work with long lines.

My text file is about 300 KB, so I think 300,000 characters.

I am 100% sure that the search string is in a text file, and the fact that the preg_match function returns a value above 0 means that he found it, but somehow it did not put it in the result array.

So my question is: how do I get it to work?

regexp will be /[specific text]\{(\d*)\}/, so of course I want to be able to get the number in parentheses.

+3
1

, . PHP 5.2, , PCRE, 100k. . , , .

? . pcre.backtrack_limit.

+9

Source: https://habr.com/ru/post/1749536/


All Articles