Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex postgres正则表达式子字符串转义字符_Regex_Postgresql - Fatal编程技术网

Regex postgres正则表达式子字符串转义字符

Regex postgres正则表达式子字符串转义字符,regex,postgresql,Regex,Postgresql,数据包含一系列格式名称: ABC123456 XYZ987654 DE-234567 询问 select distinct(substring(field, '([A-Z]{1,3})')) pref, count(*) tot from table; 用字符标识条目。 问题是:转义字符是什么?将“-”字符与字母字符一起拉。“-”字符用于选择字符序列[A-Z]。如何扩展该选择序列以包含“-”字符 “-”字符用于选择字符序列[A-Z] DAS< ->代码>仅当它位于其他字符的中间时才被解释为

数据包含一系列格式名称:

ABC123456
XYZ987654
DE-234567

询问

select distinct(substring(field, '([A-Z]{1,3})')) pref, count(*) tot from table;
用字符标识条目。 问题是:转义字符是什么?将“-”字符与字母字符一起拉。“-”字符用于选择字符序列[A-Z]。如何扩展该选择序列以包含“-”字符

“-”字符用于选择字符序列[A-Z]

DAS< <代码> ->代码>仅当它位于其他字符的中间时才被解释为范围。如果将其放在字符类的开头或结尾,它将成为一个普通字符:

select distinct(substring(field, '([A-Z-]{1,3})')) pref, count(*) tot from  table;
--                                     ^
[-A-Z]
也可以工作。

distinct
不是一个函数