2

what I would like to do is something like

select
"wise, wisdom and wiseness have a common root"  as body,
regexp_replace(body,'wis%','wise') 

to obtain

wise --> wise  
wisdom --> wise   
wiseness --> wise 

and so the result would be "wise, wise and wise have a common root"

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55

1 Answers1

4

demo:db<>fiddle

select
regexp_replace('wise, wisdom and wiseness have a common root','wis[\w]*','wise','g')
  1. RegExp wis[\w]* is searching for all words beginning with wis followed by any number of letters and digits. Use [A-Za-z] instead of [\w] if you only are interested in letters.
  2. Flag g makes it for all occurences.
S-Man
  • 22,521
  • 7
  • 40
  • 63