Avatar of rgb192
rgb192
Flag for United States of America asked on

only the inserts

I have a .sql dump file where some inserts are on multiple lines

I know that every insert line begins with 'insert' and ends with ';'

how can I get only the inserts
PHPMySQL Server

Avatar of undefined
Last Comment
rgb192

8/22/2022 - Mon
Rob

Are you looking for a regular expression?  

^INSERT[^;]+

not sure it will work for multiple lines though
rgb192

ASKER
I dont understand
do i use preg_replace or something else
ASKER CERTIFIED SOLUTION
Rob

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
rgb192

ASKER
preg_match_all("/^INSERT[^;]+/i",...)

what do I put around this statement to get data from infile and send to outfile
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
virmaior

$my_text = file_get_contents('FILENAME');
preg_match_all('/INSERT[^;*];/si',$my_text,$matches);
echo '<pre>';
print_r($matches);
echo '</pre>';
Rob

As @virmaior has shown, read the file contents into a string variable and then search it using a regular expression
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
rgb192

ASKER
thanks
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.