Sqlite3 - 为什么 GLOB 不适用于 ^ $ 边界?
Sqlite3 - why GLOB doesn't work with ^ $ boundaries?
pc@pc-host:~/MyScripts/sqltest$ sqlite3 --version
3.23.1 2018-04-10 17:39:29 4bb2294022060e61de7da5c227a69ccd846ba330e31626ebcd59a94efd148b3b
pc@pc-host:~/MyScripts/sqltest$ sqlite3 sampledb.db
sqlite> .schema students
CREATE TABLE students(id integer primary key,name text,country text, thereal real, theint integer);
sqlite> select * from students;
id name country thereal theint
---------- ---------- ---------- ---------- ----------
1 Michael usa 12.6 12
2 John usa 5.78 5
3 Jack usa 12.6 12
4 Sara usa 5.78 5
5 Sally usa 12.6 12
6 Jena usa 5.78 5
7 Nancy usa 12.6 12
8 Adam usa 5.78 5
9 Stevens usa 12.6 12
这不起作用:
sqlite> select name,country from students where name GLOB '^[A-za-z]*a$';
无输出...
但是这样做:
sqlite> select name,country from students where name GLOB '[A-za-z]*a';
name country
---------- ----------
Sara usa
Jena usa
为什么?我知道在这种情况下使用“^$”作为名称是多余的,但只是出于好奇..
The GLOB operator … uses the Unix file globbing syntax for its wildcards.
并且 Unix 文件 globbing 语法不使用 ^
/$
。
GLOB 总是匹配整个字符串,因此这些边界标记没有意义。
pc@pc-host:~/MyScripts/sqltest$ sqlite3 --version
3.23.1 2018-04-10 17:39:29 4bb2294022060e61de7da5c227a69ccd846ba330e31626ebcd59a94efd148b3b
pc@pc-host:~/MyScripts/sqltest$ sqlite3 sampledb.db
sqlite> .schema students
CREATE TABLE students(id integer primary key,name text,country text, thereal real, theint integer);
sqlite> select * from students;
id name country thereal theint
---------- ---------- ---------- ---------- ----------
1 Michael usa 12.6 12
2 John usa 5.78 5
3 Jack usa 12.6 12
4 Sara usa 5.78 5
5 Sally usa 12.6 12
6 Jena usa 5.78 5
7 Nancy usa 12.6 12
8 Adam usa 5.78 5
9 Stevens usa 12.6 12
这不起作用:
sqlite> select name,country from students where name GLOB '^[A-za-z]*a$';
无输出...
但是这样做:
sqlite> select name,country from students where name GLOB '[A-za-z]*a';
name country
---------- ----------
Sara usa
Jena usa
为什么?我知道在这种情况下使用“^$”作为名称是多余的,但只是出于好奇..
The GLOB operator … uses the Unix file globbing syntax for its wildcards.
并且 Unix 文件 globbing 语法不使用 ^
/$
。
GLOB 总是匹配整个字符串,因此这些边界标记没有意义。