GBase 8a单词首字母大写函数initcap介绍和使用样例

GBase 8a支持initcap函数,用于字符串中,每个单词的首字母转化为大写,非首字母转化为小写。

语法

initcap(expr)

expr可以是字符串,列,一个函数的结果,常量等。

字母,指unicode letter, 包括英文字母,阿拉伯数字,中文拼音,汉字,日文平假名和片假名,西欧字母等。

不能指定单词分隔符,默认是空格或者tab,换行等。

使用

英文字母

第一个字符改成了大写,非第一个的改成了小写。

gbase> select initcap('hello wORLD');
+------------------------+
| initcap('hello wORLD') |
+------------------------+
| Hello World            |
+------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase>

中文全角拼音

其实就是全角的拼音

gbase> select initcap('abc');
+----------------------+
| initcap('abc')    |
+----------------------+
| Abc               |
+----------------------+
1 row in set (Elapsed: 00:00:00.01)

分隔符

除了英文半角空格外,其它的分隔符样例如下。

换行作为单词分隔符

gbase> select initcap('hello\nwORLD');
+-------------------------+
| initcap('hello\nwORLD') |
+-------------------------+
| Hello
World             |
+-------------------------+
1 row in set (Elapsed: 00:00:00.00)

TAB作为分隔符

gbase> select initcap('hello\twORLD');
+-------------------------+
| initcap('hello\twORLD') |
+-------------------------+
| Hello World             |
+-------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select initcap('hello\t\twORLD');
+---------------------------+
| initcap('hello\t\twORLD') |
+---------------------------+
| Hello         World              |
+---------------------------+
1 row in set (Elapsed: 00:00:00.00)

中文全角空格

gbase> select initcap('hello wORLD');
+--------------------------+
| initcap('hello wORLD')  |
+--------------------------+
| Hello World             |
+--------------------------+
1 row in set (Elapsed: 00:00:00.00)

标点符号,包括全角

包括了横线,下划线等

gbase> select initcap('hello,wORLD');
+--------------------------+
| initcap('hello,wORLD')  |
+--------------------------+
| Hello,World             |
+--------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select initcap('hello,wORLD');
+------------------------+
| initcap('hello,wORLD') |
+------------------------+
| Hello,World            |
+------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select initcap('hello-wORLD');
+------------------------+
| initcap('hello-wORLD') |
+------------------------+
| Hello-World            |
+------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select initcap('hello_wORLD');
+------------------------+
| initcap('hello_wORLD') |
+------------------------+
| Hello_World            |
+------------------------+
1 row in set (Elapsed: 00:00:00.00)