Skip to content
Snippets Groups Projects
Commit e25c440c authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2427773 by sun, daffie: SQLite REGEXP user function exists, but is wrongly implemented

parent bc491331
No related branches found
No related tags found
No related merge requests found
......@@ -257,10 +257,16 @@ public static function sqlFunctionRand($seed = NULL) {
/**
* SQLite compatibility implementation for the REGEXP SQL operator.
*
* The REGEXP operator is a special syntax for the regexp() user function.
* The REGEXP operator is natively known, but not implemented by default.
*
* @see http://www.sqlite.org/lang_expr.html#regexp
*/
public static function sqlFunctionRegexp($string, $pattern) {
return preg_match('#' . str_replace('#', '\#', $pattern) . '#i', $string);
public static function sqlFunctionRegexp($pattern, $subject) {
// preg_quote() cannot be used here, since $pattern may contain reserved
// regular expression characters already (such as ^, $, etc). Therefore,
// use a rare character as PCRE delimiter.
$pattern = '#' . addcslashes($pattern, '#') . '#i';
return preg_match($pattern, $subject);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment