Re: Use ereg in scriptcase
I ran your code at:
http://writecodeonline.com/php/
Your code: adding date value
$date = '2011-10-01';
if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs)) {
echo "$regs[3].$regs[2].$regs[1]";
} else {
echo "Invalid date format: $date";
}
It returns a valid date as expected:
01.10.2011
I would suspect that SC is not handing the code properly due to the curly brackets (SC see {} as macro delimiters)
SC also uses [] as global delimiters. IMO, this us not a good selection of delimiters.
I tried adding spaces so SC did not assume it was a macro, but then it does not evaluate properly in PHP
if (ereg ("([0-9]{ 4 })-([0-9]{ 1,2 })-([0-9]{ 1,2 })", $date, $regs)) {
You may have to find another approach for this.
Regards,
Scott.