Reputation: 731
How would I go about removing a list of text within a string? Essentially have a URL column and want to avoid grossly long regexp's and multiple nested replace functions.
Is there a way to declare a list of text such as "http", "www.", etc and have them removed from the column in one go?
Upvotes: 2
Views: 6244
Reputation: 172974
You can use below simple approach
with t as (
select 'Is there a way to declare a list of text such as "http", "www.", etc and have them removed from the column in one go?' col
)
select regexp_replace(col, r'http|www.|etc', '') cleaned_col
from t
with output
Upvotes: 6