我必须检查 PostgreSQL 中以 alpha 开头的字符串。我用的是这个:
SELECT string ~ '^([a-z]|[A-Z])'
但它不适用于以拉丁字符开头的字符串。例如:ücp。
在 Java 中,我使用这个正则表达式:
^([\pL]).*
我在 PostgreSQL 上尝试过,但它没有按预期工作。
如何在 PostgreSQL 中编写这个正则表达式?
最佳答案
POSIX 字符类 [:alpha:]
与区域设置相关,并且也匹配 Unicode 字母。
使用
^[[:alpha:]]
看看docs是什么说:
Standard character class names are: alnum, alpha, blank, cntrl, digit, graph, lower, print, punct, space, upper, xdigit. These stand for the character classes defined in ctype. A locale can provide others.
关于regex - PostgreSQL 正则表达式检查以拉丁字符和字母字符开头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40717593/