2017-02-23 29 views

ответ

1
,(?=\s*\)) 

Вы можете использовать эту функцию и заменить empty string .Увидь демо.

https://regex101.com/r/rkDV4X/1

$re = '/,(?=\s*\))/'; 
$str = 'item_id IN (\'1\',\'2\',) AND nt_id IN (\'er1\',\'er2\',) AND'; 
$subst = ''; 

$result = preg_replace($re, $subst, $str); 

echo "The result of the substitution is ".$result; 
+0

спасибо много. оно работает :) – Amboom