2

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?

1
  • Please provide sample data and desired results. Commented Mar 12, 2021 at 2:31

1 Answer 1

6

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

enter image description here

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.