This loads a regular-expression matcher for posix extended regular expressions, as available through the SQLite source code repository (https://sqlite.org/src/raw?filename=ext/misc/regexp.c).

initRegExp(db)

Arguments

db

A SQLiteConnection object to add the regular expression operator into the connection.

Value

Always TRUE, invisibly.

Details

SQLite will then implement the "A regexp B" operator, where A is the string to be matched and B is the regular expression.

Note this only affects the specified connection.

Examples

library(DBI) db <- RSQLite::datasetsDb() RSQLite::initRegExp(db) dbGetQuery(db, "SELECT * FROM mtcars WHERE carb REGEXP '[12]'")
#> row_names mpg cyl disp hp drat wt qsec vs am gear carb #> 1 Datsun 710 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1 #> 2 Hornet 4 Drive 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1 #> 3 Hornet Sportabout 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2 #> 4 Valiant 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1 #> 5 Merc 240D 24.4 4 146.7 62 3.69 3.190 20.00 1 0 4 2 #> 6 Merc 230 22.8 4 140.8 95 3.92 3.150 22.90 1 0 4 2 #> 7 Fiat 128 32.4 4 78.7 66 4.08 2.200 19.47 1 1 4 1 #> 8 Honda Civic 30.4 4 75.7 52 4.93 1.615 18.52 1 1 4 2 #> 9 Toyota Corolla 33.9 4 71.1 65 4.22 1.835 19.90 1 1 4 1 #> 10 Toyota Corona 21.5 4 120.1 97 3.70 2.465 20.01 1 0 3 1 #> 11 Dodge Challenger 15.5 8 318.0 150 2.76 3.520 16.87 0 0 3 2 #> 12 AMC Javelin 15.2 8 304.0 150 3.15 3.435 17.30 0 0 3 2 #> 13 Pontiac Firebird 19.2 8 400.0 175 3.08 3.845 17.05 0 0 3 2 #> 14 Fiat X1-9 27.3 4 79.0 66 4.08 1.935 18.90 1 1 4 1 #> 15 Porsche 914-2 26.0 4 120.3 91 4.43 2.140 16.70 0 1 5 2 #> 16 Lotus Europa 30.4 4 95.1 113 3.77 1.513 16.90 1 1 5 2 #> 17 Volvo 142E 21.4 4 121.0 109 4.11 2.780 18.60 1 1 4 2