我有一个像这样的字符串:
hheelllloo wwoorrlldd !!
那应该返回hello world!
我对上述的尝试是
SELECT regexp_substr('hheelllloo wwoorrlldd !!', '.', LEVEL*2-1)l_val
FROM dual
CONNECT BY LEVEL <= LENGTH('hheelllloo wwoorrlldd !!')/2;
但这不是我需要的方式,并且没有正确使用逻辑。我也尝试过使用'(\w)\1'
我在示例数据中的预期结果:
WITH t AS
( SELECT 'hheelllloo wwoorrlldd!!' AS word FROM dual
UNION
SELECT 'hellow world!' FROM dual
UNION
SELECT 'ootthheerrss' FROM dual
UNION
SELECT 'ootthheeerrss' FROM dual
)
SELECT * FROM t;
输出应如下所示:
hello world! --expression applied
hellow world! -- not needed for non-repeated characters
others --expression applied
otheers --applied and extra `e` considered as non-repeated.
我可以在一个查询中完成整个查询,还是第一个查询?在此先感谢,这仅用于我的练习并了解不同的逻辑。