用不同的字符串替换URL

发布于 2025-01-23 07:38:58 字数 708 浏览 1 评论 0原文

我尝试将所有URL与另一个URL替换为MariadB数据库(10.3.31)

URL的示例:

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

我想替换:https://website.com/download/8fd4g8er4ger4ger4ger5f84(<哈希文件夹名称) 使用我的新URL:https://newurl.com/download/filename.zip

我过去曾经使用过“ update/replace” sql命令,但是我不知道如何处理唯一的hash像上面的名称文件夹

对我有帮助吗?


编辑:找到它

找到了:

update table_name set column_name = regexp_replace(column_name,'weblot.com/download/(.Forage':)/','newwebsite.com/download/')

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/')

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑,眼淚并存 2025-01-30 07:38:58

在这种情况下,请使用正则

UPDATE table_name SET column_name = REGEXP_REPLACE(column_name, 'website.com/download/(.*?)/', 'newUrl.com/download/');

Use Regex in this case

UPDATE table_name SET column_name = REGEXP_REPLACE(column_name, 'website.com/download/(.*?)/', 'newUrl.com/download/');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文