0

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

1 Answer 1

3

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)    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.