I’m trying to find parameters outside quotes (Single ou Double)
$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);
The above code will produce the follow result,
print_r($matches); // array(:to_email, :48, :27, :ip_from)
And I want only:
:to_email
:ip_from
Should do the trick, checking for beginning of line and white-space and make sure the RegEx query is set to multiline.
edit
This uses the passive non-capture group (?:) which puts the proper results, without the space padding into a sub array of the matches variable at index 1.