[TYPO3-core] RFC #9994: Bug: ereg_replace is deprecated in PHP 5.3 alpha3

Xavier Perseguers typo3 at perseguers.ch
Fri May 22 08:33:40 CEST 2009


Hi,

> i broke it down.
> 
> Error happens in class.t3lib_syntaxhl.php line 383
> 
> This was the line before:
> $markUpStr = 
> ereg_replace('<([[:alnum:]_]+)[^>]*>',$token.'\1'.$token,$str);
> 
> was replaced by:
> $markUpStr = 
> preg_replace('/<([[:alnum:]_]+)[^>]*>/',$token.'\1'.$token,$str); 
> (doesn't work)

I did a dumb php class to test the preg_replace and I do not understand 
why it does not work and why you need to use double quotes instead.

> I found this as working alternative:
> $markUpStr = 
> preg_replace('/<([[:alnum:]_]+)[^>]*>/',"$token\\1$token",$str);

Yes, I do not understand why it works better.

> Alternative:
> $markUpStr = preg_replace('/<([\w]+)[^>]*>/', "$token\\1$token", $str);
> 
> i'm not 100% sure if \w has too much in opposite of [:alnum:]_

There was a discussion and IIRC one did not want to do two different 
changes at once. Moreover, tests should be made with accentuated letters 
before any such change.

-- 
Xavier Perseguers
http://xavier.perseguers.ch/en

One contribution a day keeps the fork away


More information about the TYPO3-team-core mailing list