I'm trying to grab part of a string that represents a date.
The date-string will usually, but not always, have regular text before and/or after it.
In this example:
Sometimes text is here, Sun, Apr 09, 2000 And sometimes but not always text here
I would want the result to be:
Sun, Apr 09, 2000
Bear in mind that days and month strings can be 3 or 4 characters in length.
My meager attempt is:
$test = "Sometimes text is here, Sun, Apr 09, 2000 And sometimes but not always text here";
if (ereg ("/([a-z]{3,4}),.([a-z]{3,4}).([0-9]{1,2}),.([0-9]{4})/i", $test, $regs)) {
echo "$regs[4].$regs[3].$regs[2].$regs[1]";
}
Also interested in hearing non-regex based solutions.