Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在sqlite表中搜索列与正则表达式匹配的位置_Sql_Ruby On Rails_Regex_Sqlite - Fatal编程技术网

在sqlite表中搜索列与正则表达式匹配的位置

在sqlite表中搜索列与正则表达式匹配的位置,sql,ruby-on-rails,regex,sqlite,Sql,Ruby On Rails,Regex,Sqlite,我正在用Rails编写一个使用sqlite的web应用程序。我希望用户能够使用正则表达式搜索数据库中的表。这可能吗?谢谢。有。但是您必须实现该功能。是的,有一个。但是您必须实现该函数。以下是我用来实现正则表达式函数(使用PHP和PDO)的代码: 下面是我用来实现正则表达式函数(使用PHP和PDO)的代码: #to implement regex searches function php_regex_match ($regex, $str) { if (preg_match("/$reg

我正在用Rails编写一个使用sqlite的web应用程序。我希望用户能够使用正则表达式搜索数据库中的表。这可能吗?谢谢。

有。但是您必须实现该功能。

是的,有一个。但是您必须实现该函数。

以下是我用来实现正则表达式函数(使用PHP和PDO)的代码:


下面是我用来实现正则表达式函数(使用PHP和PDO)的代码:

#to implement regex searches
function php_regex_match ($regex, $str) {
    if (preg_match("/$regex/", $str, $matches)) {
     return 1; #$matches[0];
    }
 return false;
}
$db->sqliteCreateFunction('REGEXP', 'php_regex_match', 2);