split string unless enclosed betwen other strings

Momo

New Member
I know this question have been asked endless times but I can't find a working solution for my case.I want to split a string in PHP (5.3) using semicolons as delimiters unless they are between \[code\]$BODY$\[/code\] strings. The goal is to split SQL statements where statements can be procedures (postgresql in this case).Example:select; start $BODY$ begin; end; $BODY$ lang; updateShould result in:selectstart $BODY$ begin; end; $BODY$ langupdateI have been toying with \[code\]preg_split\[/code\] for a while and cannot find a working solution.Many thanksEdit: it must works with multiline inputs (but I can remove line breaks using \[code\]str_replace\[/code\] before hand)
 
Back
Top