0

I am looking (probably) for REGEXP_REPLACE() in BigQuery to remove specific strings from the end of another string.

I need to remove ".html" and ".htm" and "/" (...plus a few more strings) from the end of the following URLs:

someurl.com/page.html
someurl.com/page.htm
someurl.com/page/
someurl.com/page/

I know I need REGEXP_REPLACE() but I'm too lame to build it.

Can someone give me a little push?

Thx!

DZ

1 Answer 1

2

Use below

select 
  url, 
  regexp_replace(url, r'(.html|.htm|/)$', '') output
from t    

If applied to sample data in your question - output is

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.