Turns out there is a fairly simple solution, (thanks to Mirnal Kant)
In javascript:
//functions to be created for the db
var smDbFunctions = {
//for use as where col regexp string_for_re
// col goes as the second argument
regexp: {
onFunctionCall: function(val) {
var re = new RegExp(val.getString(0));
if (val.getString(1).match(re))
return 1;
else
return 0;
}
}
};
after instantiating a SQLite instance:
Database.createFunction("REGEXP", 2, smDbFunctions.regexp);
This does work, see Mirnal's SQLite Manager version 0.4.3 for proof of
concept.
-Original Message-
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Noah Hart
Sent: Tuesday, January 13, 2009 9:29 AM
To: General Discussion of SQLite Database
Subject: [sqlite] Assigning REGEX from javascript
BACKGROUND:
Firefox includes SQLite version 3.5.9, it also allows extensions, which
are written in javascript and can call the embedded SQLite engine.
As expected, executing the following SQL statement 'SELECT "TEXT" REGEX
"T*";' gives an error, since there is no REGEX function included.
javascript includes a native regex function.
SQLite allows loadable extensions via SELECT load_extension('filename');
QUESTION:
Is it possible to load a javascript extension which could be registered
to do REGEX?
Regards,
Noah
CONFIDENTIALITY NOTICE:
This message may contain confidential and/or privileged information. If you are
not the addressee or authorized to receive this for the addressee, you must not
use, copy, disclose, or take any action based on this message or any
information herein. If you have received this message in error, please advise
the sender immediately by reply e-mail and delete this message. Thank you for
your cooperation.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users