Why your regular expression takes the last occurrence of a substring and not the other?

Please help me. We need the regular season to write to choose what starts INSERT INTO then anything (including newline) and ends at the first occurrence of the ');' .

Here's what I made.
$result = preg_match_all("/INSERT INTO(.|\n|\r)*\)\;/i", $content, $inserts);
but it is not working. Choose from INSERT INTO to the last ');' , and it is necessary to first.
Thank you.
July 8th 19 at 16:20
1 answer
July 8th 19 at 16:22
Solution
Lazy you just.
And to be greedy.

https://learn.javascript.ru/regexp-greedy-and-lazy

The flag of the U (ungreedy) to help
https://regex101.com/r/nK7aV6/1
Thank you so much! - Holly58 commented on July 8th 19 at 16:25

Find more questions by tags ParsingPHPRegular expressions