All Forums Database
nagendratrpth 25 posts Joined 03/14
03 Jul 2015
One string out of the repetitive string series

Hi,
How to get only one word out of the repetitive word series for exanple XYZ FROM XYZ XYZ XYZ or XYZ,XYZ,XYZ or XYZ?XYZ?XYZ.
Thanks
Nagendra

dnoeth 4628 posts Joined 11/04
06 Jul 2015

Hi Nagendra,
try a regular expression:

REGEXP_SUBSTR( x,'\b(\w+)(?=\W\1\b)')

\b -> word boundary
(\w+) finds a group of letters, digits and underscores = the searched word
(?=\W\1\b) checks if the previous word is repeated without adding it to the result
\W is any other character besides letters, digits and underscores
\1 the previous word 

Dieter

You must sign in to leave a comment.