PDA

View Full Version : Reg Exp help


JTyson
10-28-2005, 12:45 PM
Hey guys, hopefully someone can help me with this, Im working on a script that parses another php file for an import, The file contains an insert statement that i neeed to extract the insert values from. I already have the files contents loaded into a var and i can extract the values i need using a messy combination of substr etc.

So for an example
INSERT INTO " . TABLE_PREFIX . "tablename (field,field) VALUES (blah,blah)

I need to extract "blah,blah" into a string somehow, anyone have any idea's?

Cheers

akanevsky
10-28-2005, 05:25 PM
If you already have "blah,blah", then why do you need to extract it? Please post the full code.

JTyson
10-28-2005, 05:48 PM
It's kind of complicated and i'll try and explain it a bit better.

What i am doing is extracting a php file from a zip archive the contents of the extracted file are stored in a var, now at the moment i know i can get it working by writing outputing that var to a temp text file then looping through it line by line untill i find the correct insert statement and then disecting the line to get the values i need from the insert statement, I was more hoping that someone could help me with a pattern to find the insert statement in the var without having to write it out to a file first.

at the moment there is no code but i know that i could do it the way above but would rather not have to write it out to a temp file.

Cheers

akanevsky
10-28-2005, 06:22 PM
Nobody can help you without knowing exactly what you trying to do.
You might wanna post your code here.