如何在 postgresql 中用词根替换单词?

How can I replace a word with its root in postgresql?

我想做的是

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

获得

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

所以结果是 "wise, wise and wise have a common root"

demo:db<>fiddle

select
regexp_replace('wise, wisdom and wiseness have a common root','wis[\w]*','wise','g')
  1. RegExp wis[\w]* 正在搜索以 wis 开头后跟任意数量的字母和数字的所有单词。如果您只对字母感兴趣,请使用 [A-Za-z] 而不是 [\w]
  2. Flag g 使其适用于所有事件。