Page 1 of 1

string

Posted: Sat Aug 06, 2005 10:30 pm
by zolo44
I'm having trouble with this problem. Hopefully somebody can help me.

Problem:

Using php, I need to create an array with all the matches of the strings starting with the word "INSERT" and end with the ";".

Now, since im new to all this, i thinking I need to use the preg_split() right? Or is something better then this?


Tried using something like this but is not working... probably don't have the right understanding of how it works yet.

Code: Select all

/CREATE.*;$/
Any help will be appreciated.

Posted: Sat Aug 06, 2005 10:36 pm
by feyd
try

Code: Select all

preg_match_all('#(?:^|;)\s*insert\s*(.*?)(?:;|$)#i',$data,$matches);
print_r($matches);

Re: string

Posted: Sat Aug 06, 2005 10:37 pm
by anjanesh
zolo44 wrote: an array with all the matches of the strings starting with the word "INSERT" and end with the ";".

Code: Select all

preg_match_all("/INSERT.*?;/is", $sqlContents, $matches)
print_r($matches);

Posted: Sat Aug 06, 2005 11:04 pm
by zolo44
thanks guys, they both worked.