$string='April15,2003';$pattern='/(\w+)(\d+),(\d+)/i';$replacement='${1},${3}';echo preg_replace($pattern,$replacement,$string);
?>
Results for April1, 2003
Why (w+) matches April 1 without matching April 15
Is it because: W itself will match the number, if the 5 is also matched, then D there is no match to the thing
Reply content:
$string='April15,2003';$pattern='/(\w+)(\d+),(\d+)/i';$replacement='${1},${3}';echo preg_replace($pattern,$replacement,$string);
?>
Results for April1, 2003
Why (w+) matches April 1 without matching April 15
Is it because: W itself will match the number, if the 5 is also matched, then D there is no match to the thing
w+ can match April15 completely, but you wrote d+ behind w+, in order to match the rules you defined, April1 gave w,5 to D.
$pattern='([a-z]+)(\d+),(\d{4})/i';
is in line with the requirements
$pattern = '/(w+) (d{1,2{+), (d+)/I '; this looks like the landlord wants the date