public static function Connection::sqlFunctionRegexp

public static Connection::sqlFunctionRegexp($pattern, $subject)

SQLite compatibility implementation for the REGEXP SQL operator.

The REGEXP operator is natively known, but not implemented by default.

See also

http://www.sqlite.org/lang_expr.html#regexp

File

core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php, line 272

Class

Connection
SQLite implementation of \Drupal\Core\Database\Connection.

Namespace

Drupal\Core\Database\Driver\sqlite

Code

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);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Database!Driver!sqlite!Connection.php/function/Connection::sqlFunctionRegexp/8.1.x