我有以下字符串:
String 1: abcde?dafsdfdsfsd
String 2: absdfcde?dafsdfdsfsdsfdsdfd
想在“?”之后删除任何内容
预期产出:
String 1: abcde
String 2: absdfcde
答案 0 :(得分:3)
使用split_part()
,例如:
with my_data(col) as (
values
('abcde?dafsdfdsfsd'),
('absdfcde?dafsdfdsfsdsfdsdfd')
)
select split_part(col, '?', 1)
from my_data;
split_part
------------
abcde
absdfcde
(2 rows)