[yunqa.de] Re: disqlite and regular expressions

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Sun, 14 Sep 2014 11:47:42 +0200

On 13.09.2014 16:09, LucDeSa wrote:

> I use both Disqlite pro and Diregex.
>
> Is there anybody who can provide an example of using the regular 
> expression functions within Disqlite3regexp ?

The DISQLite3RegExp.pas unit is documented in DISQLite3.chm. An example console 
project follows below.

Ralf

----------------

{ DISQLite3 console project to demonstrate the use of DISQLite3RegExp.pas.
  Deliberately kept short to focus on essentials. Not for production use. }
program DISQLite3_regex;

{$APPTYPE CONSOLE}

uses
  DISQLite3Api, DISQLite3RegExp;

var
  DB: sqlite3_ptr;

  { Helper to print SQL results. }
procedure Exec(const SQL: RawByteString);
var
  nCol: Integer;
  Stmt: sqlite3_stmt_ptr;
begin
  WriteLn(SQL);
  sqlite3_check(sqlite3_prepare_v2(DB,
    PAnsiChar(SQL), Length(SQL) + 1, @Stmt, nil), DB);
  while sqlite3_check(sqlite3_step(Stmt), DB) = SQLITE_ROW do
    for nCol := 0 to sqlite3_column_count(Stmt) - 1 do
      WriteLn('    ', sqlite3_column_str(Stmt, nCol));
  sqlite3_check(sqlite3_finalize(Stmt));
end;

begin
  sqlite3_open('test.db3', @DB);

  { Register the SQL regexp() user function to support the REGEX operator. }
  sqlite3_create_function_regexp(DB);
  { Simple SQL using the REGEX operator. }
  Exec('SELECT ''123abc'' REGEXP ''\d+''');

  sqlite3_check(sqlite3_close(DB));

  WriteLn;
  WriteLn('Done - Press ENTER to Exit');
  ReadLn;
end.
_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: