编译失败:P或P之后的未知属性名称


Compilation failed: unknown property name after P or p

嗨,我想匹配一个字符串:"'par hello 'par world"

针对我的regexp模式->''par

然而,我得到了一个Compilation failed: unknown property name after 'P or 'p

我相信我的regexp规则被视为unicode字符属性。如何逃离它并按原样运行模式?

我把它包含在PDO函数中,就像这样。

function sqlite_regExp($sql,$db)
{
    if($db->sqliteCreateFunction("regexp", "preg_match", 2) === FALSE) exit("Failed creating function!");
    if($res = $db->query($sql)->fetchAll()){ return $res; }
    else return false;
}

我这样调用函数

sqlite_regExp("SELECT COUNT(*) FROM table WHERE REGEXP('/''par/',column) ",$db)

您需要3个后拉'''。检查此示例:

$string = "'par hello 'par world";
$pattern = '/'''par/';
preg_match_all($pattern, $string, $matches);
var_dump($matches);

您可以在PHP手册中找到更多信息

您已经更新了问题,我看到您没有使用preg_match,而是使用SQL REGEXP函数。但是,SQL函数也应该与'''一起使用。