Help with this model

Hello experts;

I have the following query below example.

with data such as (select "text NWC me' as a Word, as the double id 1")

Union of all the

Select 'Zone out' as a Word, double id 2

Union of all the

Select "pj NWC" as a Word, as the double id 3

Union of all the

Select 'place jknwc' as a Word, as the double id 4

Union of all the

Select "jkndcNWC" as a Word, as the double id 5

)

Select * from data

I would like the following results

Word New_word Id

Text of NOC me text me 1

Area area 2

pj NWC                  pj                        3

jknwc somewhere jknwc 4

jkndcNWC jkndcNWC 5

The result of the fact THAT NOC is usually removed from the beginning of the word, if it is a stand-alone and the end of the word if it is autonomous. Any help is appreciated.

Thank you

Select

Word

, regexp_replace (Word, ' ^ (OF\W) NWC\W?: \WNWC(\WOF)?$') new_word

from the data

Tags: Database

Similar Questions

Maybe you are looking for