# 维基图片链接问题求助

**URL:** <https://forum.freemdict.com/t/topic/22239>\
**Category:** 词典及语言学习交流\
**Tags:** 求助\
**Created:** [2023 年7 月 19 日 09:40 UTC](https://forum.freemdict.com/t/topic/22239 "2023-07-19T09:40:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

作者： ![xmg123](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/x/7cd45c/32.png) [@xmg123](https://forum.freemdict.com/u/xmg123)\
发布日期： [2023 年7 月 19 日 09:40 UTC](https://forum.freemdict.com/t/topic/22239/1 "2023-07-19T09:40:48Z")

</div>

![](https://forumcdn.freemdict.com/uploads/default/original/3X/c/d/cdc74538f75ca2260bf71cf0015ee2178e8f06a4.png)  
这个图，怎么用正则批量删除最后一节/之前的内容，没一个链接的/包含的数量都不一样，我想保留最后一节/之后的内容，没找到好的方法，求助论坛有人知道吗？

---

<div class="post-metadata">

作者： ![zheshijie](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/z/73ab20/32.png) [@zheshijie](https://forum.freemdict.com/u/zheshijie)\
发布日期： [2023 年7 月 19 日 09:52 UTC](https://forum.freemdict.com/t/topic/22239/2 "2023-07-19T09:52:10Z")

</div>

.\*([^/]+$)替换为\1

---

<div class="post-metadata">

作者： ![xmg123](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/x/7cd45c/32.png) [@xmg123](https://forum.freemdict.com/u/xmg123)\
发布日期： [2023 年7 月 19 日 10:07 UTC](https://forum.freemdict.com/t/topic/22239/3 "2023-07-19T10:07:52Z")

</div>

![](https://forumcdn.freemdict.com/uploads/default/original/3X/3/8/38e28774fa3d2bee3a24ad4d57bbfb17330e9d4b.jpeg)  
那上面这个咋办？我想保留最后一节，想弄成mdx格式图片img src=“\*.jpg”，就是/内容的数量有多有少3

---

<div class="post-metadata">

作者： ![xmg123](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/x/7cd45c/32.png) [@xmg123](https://forum.freemdict.com/u/xmg123)\
发布日期： [2023 年7 月 19 日 15:16 UTC](https://forum.freemdict.com/t/topic/22239/4 "2023-07-19T15:16:03Z")

</div>

…比如src="[//upload.wikimedia.org/wikipedia/commons/thumb/c/c3/SMS\_Kaiser\_Barbarossa\_Bain\_picture.jpg/380px-SMS\_Kaiser\_Barbarossa\_Bain\_picture.jpg](https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/SMS_Kaiser_Barbarossa_Bain_picture.jpg/380px-SMS_Kaiser_Barbarossa_Bain_picture.jpg)

匹配时  
src="[//upload.wikimedia.org/](https://upload.wikimedia.org/)._?/._?/._?/._?/._?/._?/  
笨方法能想到的只是这样子，按最长的匹配完，再依次从长到短匹配

---

<div class="post-metadata">

作者： ![zongze](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/z/ba8739/32.png) [@zongze](https://forum.freemdict.com/u/zongze)\
发布日期： [2023 年7 月 19 日 15:42 UTC](https://forum.freemdict.com/t/topic/22239/5 "2023-07-19T15:42:58Z")

</div>

```auto
src="[^"]+\/([^\/"]+?)" 替换成 src="\1"

```

---

<div class="post-metadata">

作者： ![xmg123](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/x/7cd45c/32.png) [@xmg123](https://forum.freemdict.com/u/xmg123)\
发布日期： [2023 年7 月 19 日 16:09 UTC](https://forum.freemdict.com/t/topic/22239/6 "2023-07-19T16:09:31Z")

</div>

成了，非常感谢
