One string out of the repetitive string series

Database
Enthusiast

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

Tags (1)
1 REPLY
Junior Contributor

Re: One string out of the repetitive string series

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