本文介绍了编译失败:不支持POSIX整理元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了一个网站&旧版CMS到我们的服务器上,并且出现POSIX编译错误.幸运的是,它只出现在后端,但是客户渴望摆脱它.

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

据我所知,这是导致该问题的PHP的较新版本.这是代码:

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;

}

我如何调整它以便在此服务器上的较新版本的php上工作?

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.

所以[abcd]将与a or b or c or d匹配.

如果要匹配多个字符的替换,例如red or blue or yellow,请使用子模式:

If you want to match alternations of more than one character, for example red or blue or yellow, use a sub pattern:

"(red|blue|yellow)"

您猜到了,[abcd]等同于(a|b|c|d).

这是您可以为正则表达式执行的操作:

So here is what you could do for your regex:

对于

$trenner = "[\040|\n|\t|\r]*";

改为写这个:

$trenner = "[\040\n\t\r]*";

还有

"[=\"|=\'|=\\\\|=]"

你可以做

"(=\"|=\'|=\\\\|=)"

"=[\"'\\\\]?"

顺便说一句,您可以使用\s而不是$trenner(请参见 http://www.php.net/manual/zh/regexp.reference.escape.php )

BTW you could use \s instead of $trenner (see http://www.php.net/manual/en/regexp.reference.escape.php)

这篇关于编译失败:不支持POSIX整理元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 04:28