I have a url column in my database. I want to remove all characters after ? .
select regexp_replace(page_url,'?(.*)', '') as clean_url from demo
But I’m getting the following error: Invalid regular expression: ‘?(.*)’, no argument for repetition operator: ?
Advertisement
Answer
Using LEFT
and CHARINDEX
:
SELECT IFF(CHARINDEX('?', page_url)>0, LEFT(page_url, CHARINDEX('?', page_url)), page_url) AS clean_url FROM demo