Reputation: 348
<?php
$str='00160.Day';
$pattern = "/(.+?)('.Day')/i";
$replacement = "\${1}";
print preg_replace($pattern, $replacement, $str);
?>
Why the output is 00160.Day
,not 00160
?What is the matter with my Minimum matching regular expression?
Upvotes: 0
Views: 42
Reputation: 3509
Single Quote '
around day is cause of unexpected output. .
should also be escaped. Use below pattern.
"/(.+?)(\.Day)/i";
Upvotes: 4