3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re = '/\) VALUES (.+?(?=\)))/m'; $str = 'INSERT INTO table (`col1`, `col2`, `col3`) VALUES (\'oneVal\', \'twoVal\', \'threeVal\')'; $subst = ',`col4`) VALUES $1 , \'1\''; $result = preg_replace($re, $subst, $str); echo $result;
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
INSERT INTO table (`col1`, `col2`, `col3`,`col4`) VALUES ('oneVal', 'twoVal', 'threeVal' , '1')

preferences:
218.84 ms | 403 KiB | 225 Q