Regex, um Inhalte zu finden, die nicht in Anführungszeichen stehen
Ich versuche, Parameter außerhalb von Anführungszeichen zu finden (einfach oder doppelt)
$sql = "
INSERT INTO Notifify (to_email, msg, date_log, from_email, ip_from)
VALUES
(
:to_email,
'test teste nonono',
'2013-02-01 10:48:27',
'bar@foo',
:ip_from
)
";
$matches = array();
preg_match_all('/:[A-Za-z0-9_]*/', $sql, $matches);
Der obige Code erzeugt das folgende Ergebnis:
print_r($matches); // array(:to_email, :48, :27, :ip_from)
Und ich will nur:
:to_email
:ip_from