Oracle数据库正则表达式用于重复字符组 [英] Oracle Database Regex For Repeating Group of Characters

查看:439
本文介绍了Oracle数据库正则表达式用于重复字符组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为我的问题很简单.我的案例包括:

I think my question is quite straightforward. Examples for my case are:

ababababab
acacacacac
adadadadad
...
azazazazaz

我需要一个可以检测到我上面提到的所有情况的正则表达式.

I need a regex that can detect all the cases I mentioned above.

我尝试使用:

(a\w){5}

但是它不能通过,因为它也通过了:

But it doesn't work as it also passes:

abacadaeaf

感谢您的帮助.

推荐答案

使用Oracle正则表达式支持的反向引用:

Use backreferences, which are supported by Oracle regular expressions:

(a\w)\1{4}

\n指第 n 个捕获组(用开括号括起来).

\n refers to the nth capture group (as counted by opening parentheses).

这篇关于Oracle数据库正则表达式用于重复字符组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆