سلام
امیدوارم به کارتون بیاد:
تستش: https://regex101.com/r/EzqHBz/1کد:<?php $str = 'admin.php?user=alireza&sa=y&SID=0ahUKEwiO3u2Ji&access=14587&commment=yes'; preg_match_all('/SID=\w*/', $str, $matches); var_dump($matches);
برای جایگزینی هم:
کد:<?php $str = 'admin.php?user=alireza&sa=y&SID=0ahUKEwiO3u2Ji&access=14587&commment=yes'; echo preg_replace('/SID=\w*/', '', $str);