'Replace URL with different string
I try to replace all my URL with another into my mariadb database (10.3.31)
URL's Example :
https://website.com/download/8fd4g8er4ger5f84/filename.zip
https://website.com/download/fggf4hf5gh4/filename.zip
https://website.com/download/1v8t77hth/filename.zip
https://website.com/download/fgh48rt4g/filename.zip
I want to replace : https://website.com/download/8fd4g8er4ger5f84 (< this using different hash folder name)
with my new URL : https://newurl.com/download/filename.zip
I used "update / replace" SQL command in the past, but I don't know how to do with unique hash name folder like above
Help me please?
EDIT : Found it
Found it :
UPDATE table_name SET column_name = REGEXP_REPLACE(column_name, 'website.com/download/(.*?)/', 'NEWwebsite.com/download/')
Solution 1:[1]
Use Regex in this case
UPDATE table_name SET column_name = REGEXP_REPLACE(column_name, 'website.com/download/(.*?)/', 'newUrl.com/download/');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
