- preg_match: documentation ( source)
<?php
$str = "I will turn 30\non January 5";
$regex = '/(\d+).*?on ([^ ]+) (\d+)/s';
if (preg_match($regex, $str, $matches)) {
echo 'Age = ' . $matches[1] . "\n";
echo 'Month = ' . $matches[2] . "\n";
echo 'Day = ' . $matches[3] . "\n";
}
?>