Reputation: 7270
I have the following string:
String 1: abcde?dafsdfdsfsd
String 2: absdfcde?dafsdfdsfsdsfdsdfd
Want to remove anything after "?"
Expected output:
String 1: abcde
String 2: absdfcde
Upvotes: 0
Views: 1034
Reputation: 121889
Use split_part()
, e.g.:
with my_data(col) as (
values
('abcde?dafsdfdsfsd'),
('absdfcde?dafsdfdsfsdsfdsdfd')
)
select split_part(col, '?', 1)
from my_data;
split_part
------------
abcde
absdfcde
(2 rows)
Upvotes: 3