我有以下几部PHP代码,用于配对一年:
$pattern = "/20dd/";
$exp = "BORN ON: Friday, June 11, 2001 ";
$match = preg_match($pattern,$exp, $matches);
echo $matches[0];
This matches "2001"
...which is what I am trying to match--the birth year. But this is clearly a hack of a solution and can run into problems if there are other years before $exp
for some reason.
How can I include the "BORN ON"
information to pick out just the year?