Aşağıdaki örnekte, bir kalıp tanımlayıp, o kalıba uyan tüm parçaları başka birşey ile değiştireceğiz.


Örnek


$string = 'Hello today is 2010-12-31T23:13:43+0001 and fun time ...';

$ISO8601pattern = '/\b(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\+(\d{4})\b/';

echo preg_replace($ISO8601pattern, 'MY FAVORITE DAY', $string);

Sonuç


Hello today is MY FAVORITE DAY and fun time ...