[Solved] Finding month preg-match


I make a snippet for you, so you can start from here

$str="December 2012 Name: Jack Brown";
$ptr = "/^(?P<month>:Jan(?:uary)?|Feb(?:ruary)?|Dec(?:ember)?) (?P<year>:19[7-9]\d|2\d{3}) (Name:(?P<name>(.*)))/";
preg_match($ptr, $str, $data);
echo 'For '.trim($data['name']).' - '.$data['month'].' '.$data['year'];

the result will be

'For Jack Brown - December 2012'

this is a array

Array
(
    [0] => December 2012 Name: Jack Brown
    [month] => December
    [1] => December
    [year] => 2012
    [2] => 2012
    [3] => Name: Jack Brown
    [name] =>  Jack Brown
    [4] =>  Jack Brown
    [5] =>  Jack Brown
)

also i try with

'February 2005 Name: Bob' => 'For Bob - February 2005'

ps. you can add more month i just lazy to add, cheers

solved Finding month preg-match