PostgreSQL - 查询所有重复数字相同的多位数字 (repdigit, "Schnapszahl")
PostgreSQL - query all multidigit numbers with repeating digits identical (repdigit, "Schnapszahl")
我只想要标有数字的条目
1234
11983455
6526347
11
207555
777
343333987
34678
这个正则表达式似乎可以做到:
select nr
from numbers
where nr::text ~ '([0-9])()';
([0-9])
为单个数字创建一个组。 ()
引用正则表达式中的第一组。所以 ([0-9])()
表示:“一个数字后跟相同的值”
样本数据的输出是:
with numbers (nr) as (
values
(1234),(11983455),(6526347),(11),(207555),(777),(343333987),(34678)
)
select nr
from numbers
where nr::text ~ '([0-9])()';
nr
---------
11983455
11
207555
777
343333987
虽然我只认为11和777是一个"Schnapszahl"
我只想要标有数字的条目
1234
11983455
6526347
11
207555
777
343333987
34678
这个正则表达式似乎可以做到:
select nr
from numbers
where nr::text ~ '([0-9])()';
([0-9])
为单个数字创建一个组。 ()
引用正则表达式中的第一组。所以 ([0-9])()
表示:“一个数字后跟相同的值”
样本数据的输出是:
with numbers (nr) as (
values
(1234),(11983455),(6526347),(11),(207555),(777),(343333987),(34678)
)
select nr
from numbers
where nr::text ~ '([0-9])()';
nr
---------
11983455
11
207555
777
343333987
虽然我只认为11和777是一个"Schnapszahl"