i am trying to use regular expressions to extract singular sql statements from a file containing several sql statements and alternate delimiters/comments.
i am trying to match the following patterns to isolate sql statements, then after isolating an individual statement, stripping it of comments:
"delimiter (del) (nonwhitespace sequence) (not (del) or comment with (del)) (del)"
"(not ; ) ;"
the first pattern should allow the use of any set of characters for a delimiter
What I have tried:
i tried the following to match the first pattern:
and if the first pattern fails, to match the second pattern:
to match the second case
then if either succeeds, replace the following with empty string:
my problem is that apache crashes on preg_match when i try to search for either of the first 2 regular expressions on the following string:
create table MovieDetail
imdbid varchar(32) primary key not null,
detect this text as a separate statement"
i tried replacing escape sequences with // like //s and //g and it still crashes just the same
i'm using XAMPP with Apache 2.4.17 and PHP 5.6.23 (VC11 X86 32bit thread safe) + PEAR
i tried testing them on debugex.com and both expressions are valid.
major update: it seems as if the problem only manifests itself when i use run the expressions on multi-line strings, so i'm going to try comparing the binary data of 2 strings where i replace the line break with \n or \r\n
update: the problem seems to occur only with multiple whitespace characters.