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
(
You can use a negative look-behind. This way you will match exactly what's needed.
preg_match_all('/(?<!\w):[a-z0-9_]+/', $sql, $matches);
Demo
'/^\\s*:[A-Za-z0-9_]*/m'
Should do the trick, checking for beginning of line and white-space and make sure the RegEx query is set to multiline.
edit
preg_match_all('/(?:^\\s*)(:[A-Za-z0-9_]+)/m', $sql, $matches);
print_r($matches[1]);
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.
What about this:
/\s+:[A-Za-z0-9_]*/
It's not very rigorous and might fail for more complex examples like like tennis scores (15 : 30
) but is probably good enough for your needs.