The current dev branch of DBD-SQLite (1.26_05) includes an implementation of
SQLite's unimplemented REGEX function
(http://search.cpan.org/~adamk/DBD-SQLite/lib/DBD/SQLite.pm#REGEXP_function).
Presumably, this will survive to the next production release.
Otherwise, DBD-SQLite offers a custom function interface where you can write
custom SQL functions in Perl. Perhaps something like
$dbh->func( 'pattern_match', 2, sub { my ($input, $regex) = @_; return ($input
=~ m/$regex/); }, 'create_function' );
and your SQL might be
select foo from mytable where pattern_match(foo, 'A[BCD]D[AD]BB') > 0;
Sorry, it's untested, off the top of my head.
-Clark
----- Original Message ----
From: "Farkas, Illes" <[email protected]>
To: [email protected]
Sent: Thu, October 15, 2009 2:24:16 PM
Subject: [sqlite] regular expression search
Hi,
I have strings in a database and I would like to find all of them
matching a pattern that is 5-10 characters long. In each position of
the pattern up to three different characters may be allowed. This
would be a typical regular expression that I'd like to find:
A (B | C | D ) D ( A | D ) B B
(I use the Perl DBI with sqlite3)
Any help would be greatly appreciated. Thanks!
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users