Results 1 to 5 of 5

Thread: SQLite : regexp

  1. #1
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527

    Unanswered: SQLite : regexp

    Can anyone explain (using simple words) how I can get regexp to work? I have a windows 7 PC but obviously users of the end product might be on anything. Are there libraries I can call up and use etc?

    Cheers Mike

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Regular expressions?
    Good tutorial / introduction: Regular Expression Tutorial - Learn How to Use Regular Expressions
    George
    Home | Blog

  3. #3
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    George! you're still here. Nice to hear from you
    I've been away for yonks for various reasons.

    I'm very familiar with regexp but what's currently frustrating me is that I can't use regexp with SQLite (actually SQLite3). It says I need a user plugin but offers no further advice. I ideally just want something that I can say "include this library" and it all works. Something tells me though that it's going to be a touch more difficult.

    How is everybody?

    Mike

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    How are we? Busy and obnoxious will do for me, thanks!

    Because SQL-Lite is actually compiled into the code you are creating, it is possible to add/remove/override much of its functionality with your own code. I think that Glob() is included by default and that regexp() needs to be included in your source code in order to get LIKE to function correctly but you'll have to check the docs at sqllite.org - SQL Server Resources and Information. This website is for sale! to be sure.

    As a side note, be sure that you understand the platform specific details for LIKE. The LIKE expression within SQL-Lite is expected to use the local OS regular expressions rather than a standard set like the *nix one that Glob() uses. You can certainly implement whatever your application needs, but the users might be annoyed if they aren't aware of your choices!

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  5. #5
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Hi Pat, glad to hear your busy but obnoxious is a bit of a dramatic change isn't it? Perhaps I should pop into the lounge and say hello. I'm just supplying the SQL to run for application and regexp would just suit my needs. Something like:

    -- to get rid of a year
    update books
    set title = replace( str, "[12][0-9][0-9][0-9]", "" )
    where title regexp "[(][12][0-9][0-9][0-9][)]";

    but I'm not sure I can use regexp like this in SQLite, especially in the replace. I'm a bit of a newcomer at SQLite and the concept is quite different to what I'm used to.

    Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •