I’ve just installed a website & legacy CMS onto our server and I’m getting a POSIX compilation error. Luckily it’s only appearing in the backend however the client’s keen to get rid of it.
Warning: preg_match_all() [function.preg-match-all]: Compilation failed:
POSIX collating elements are not supported at offset 32 in
/home/kwecars/public_html/webEdition/we/include/we_classes/SEEM/we_SEEM.class.php
on line 621
From what I can tell it’s the newer version of PHP causing the issue. Here’s the code:
function getAllHrefs($code){
$trenner = "[\040|\n|\t|\r]*";
$pattern = "/<(a".$trenner."[^>]+href".$trenner."[=\"|=\'|=\\\\|=]*".$trenner.")
([^\'\">\040? \\\]*)([^\"\' \040\\\\>]*)(".$trenner."[^>]*)>/sie";
preg_match_all($pattern, $code, $allLinks); // ---- line 621
return $allLinks;
}
How can I tweak this to work on the newer version of php on this server?
Thanks in advance, my voodoo just isn’t strong enough 😉
[...]are character classes, they match any character between the brackets, you don’t have to add|between them. See character classes.So
[abcd]will matcha or b or c or d.If you want to match alternations of more than one character, for example
red or blue or yellow, use a sub pattern:And you guessed,
[abcd]is equivalent to(a|b|c|d).So here is what you could do for your regex:
For
Write this instead:
And for
You could do
Or
BTW you could use
\sinstead of$trenner(see http://www.php.net/manual/en/regexp.reference.escape.php)