Bruno Augusto <imagg...@gmail.com> wrote: > So, I know I need a user function to use the REGEXP operator. But most of > the implementations I'd found (in PHP, I have to say) requires TWO > parameters, the Regular Expression and the string to match.
That's not a problem. SQLite takes an expression of the form a REGEXP b and automatically rewrites it as regexp(a, b), calling the user-defined function. > I created an SQLITE database where the Regular Expressions is already > stored, and I would like to send a raw string to retrieve the correspondent > result. > > E.g.: > > In the database's column 'URI', I have the following values: /(.*?) and > /main(.*?) > > I would like to send a query similar to: SELECT * FROM `table` WHERE `URI` > REGEXP( '/main/' ) Drop forward slashes. They have no special meaning in regexp syntax, and are treated as literal characters. This means that '/main(.*?)' doesn't in fact match '/main/', but does match 'main'. Some programming languages use forward slashes as delimiters around regular expressions, but SQL doesn't. Also, while it's not quite clear what you are trying to do, it seems that the values in URI column resemble the regexp syntax. Do you want to use them as regexps to match against a string literal? You can write WHERE '/main/' REGEXP URI Arguments on either side of REGEXP operator can be arbitrary SQL expressions, they are not limited to string literals. Finally, for a simple substring search, you can use LIKE or GLOB operators, the implementation for which is built into SQLite: SELECT * FROM MyTable WHERE URI LIKE '%main%'; SELECT * FROM MyTable WHERE URI GLOB '*main*'; -- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users