我的数据库(PostgreSQL)中有很多字符串,例如:
with mystrings as (
select 'H e l l o, how are you'::varchar string union all
select 'I am fine, t h a n k you'::varchar string union all
select 'This is s t r a n g e text'::varchar string union all
select 'With c r a z y space b e t w e e n characters'::varchar string
)
select * from mystrings
有没有办法可以删除单词中字符之间的空格?对于我的示例,结果应该是:
Hello, how are you
I am fine, thank you
This is strange text
With crazy space between characters
我从 开始replace
,但是有很多这样的单词,字符之间有空格,我什至找不到它们。
因为可能难以有意义地连接字符,所以最好只获取连接候选者的列表。使用示例数据,结果应该是:
H e l l o
t h a n k
s t r a n g e
c r a z y
b e t w e e n
当至少有三个由两个空格分隔的单独字符时,此类查询应查找并返回字符串中的所有子字符串(并继续直到[space] individual character
出现模式):
He l l o how are you --> llo
H e l l o how are you --> Hello
C r a z y space b e t w e e n --> {crazy, between}