Reputation: 67
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
Upvotes: 0
Views: 1114
Reputation: 172993
Use below
select
url,
regexp_replace(url, r'(.html|.htm|/)$', '') output
from t
If applied to sample data in your question - output is
Upvotes: 2