it's possible to use REGEXP in a select statement like this: SELECT * from table_name WHERE Path REGEXP 'regular expression'
before you can use REGEXP you have to use the function sqlite3_create_function(db, "regexp", 2, SQLITE_ANY,(void*)pAppPointer,&sqlite3_RegExpFunction,0,0) to tell SQLITE to map REGEXP keyword to your function and than you have to implement the function static void sqlite3_RegExpFunction(sqlite3_context* context, int argc, sqlite3_value** values){ CAppPointer* pAppPointer=(CAppPointer*)sqlite3_user_data(context); char* reg = (char*)sqlite3_value_text(values[0]); char* text = (char*)sqlite3_value_text(values[1]); if ( (argc != 2) || (reg == 0) || (text == 0) ){ sqlite3_result_error(context, "SQL function regexp() called with invalid arguments.\n", -1); return; } //item not match return sqlite3_result_int(context, 0); //item match return sqlite3_result_int(context, 1); } Il 12/01/2011 12.40, Bruno Augusto ha scritto: > Hi, > > I hope I'm doing the right thing. I never used Mailing Lists before. > > 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. > > 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/' ) > > And the record to be returned would be, in the example case, the second, > which have the text "main". > > Is that possible? Maybe adding an UDF? > -- Selea s.r.l. Michele Pradella R&D SELEA s.r.l. Via Aldo Moro 69 Italy - 46019 Cicognara (MN) Tel +39 0375 889091 Fax +39 0375 889080 *michele.prade...@selea.com* <mailto:michele.prade...@selea.com> *http://www.selea.com* _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users