RegExp查找具有相同数字的数字 [英] RegExp Find Numbers that have All Same Digits
问题描述
我正在使用Oracle数据库,并且想编写一个REGEXP_LIKE表达式来查找所有数字都相同的任何数字,例如"999999999"或"777777777",而不指定字段的长度.另外,我希望它也能够识别字符,例如'aaaaa'.
I am working with an Oracle database and would like to write a REGEXP_LIKE expression that finds any number where all digits are the same, such as '999999999' or '777777777' without specifying the length of the field. Also, I would like it to be able to identify characters as well, such as 'aaaaa'.
使用以下命令,我可以在指定字段长度时使其工作:
I was able to get it working when specifying the field length, by using this:
select * from table1
where regexp_like (field1, '^([0-9a-z])\1\1\1\1\1\1\1\1');
但是我希望它能够在任何字段长度下都可以做到这一点.
But I would like it to be able to do this for any field length.
例如,如果一个字段包含"7777771",则我不想在结果中看到它.
If a field contains '7777771', for example, I would not want to see it in the results.
推荐答案
尝试一下:
^([0-9a-z])\1+$
这篇关于RegExp查找具有相同数字的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!