Oracle SQL-从字符串中删除部分重复 [英] Oracle SQL -- remove partial duplicate from string
本文介绍了Oracle SQL-从字符串中删除部分重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张桌子,桌子上有一列看起来像这样的字符串:
I have a table with a column with strings that looke like this:
static-text-here/1abcdefg1abcdefgpxq
从此字符串1abcdefg
重复两次,所以我想删除该部分字符串,然后返回:
From this string 1abcdefg
is repeated twice, so I want to remove that partial string, and return:
static-text-here/1abcdefgpxq
我无法保证重复字符串的长度.在纯SQL中,如何执行此操作?
I can make no guarantees about the length of the repeat string. In pure SQL, how can this operation be performed?
推荐答案
如果您可以保证重复字符串的最小长度,则可以执行以下操作:
If you can guarantee a minimum length of the repeated string, something like this would work:
select REGEXP_REPLACE
(input,
'(.{10,})(.*?)\1+',
'\1') "Less one repetition"
from tablename tn where ...;
我相信可以扩展到更明智地满足您的要求.
I believe this can be expanded to meet your case with some cleverness.
这篇关于Oracle SQL-从字符串中删除部分重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文