# 求教—— txt中 如何将 @@@link=xxx 替换为原词条内容

**URL:** <https://forum.freemdict.com/t/topic/14514>\
**Category:** 技术交流与词典编修\
**Created:** [2022 年8 月 7 日 04:51 UTC](https://forum.freemdict.com/t/topic/14514 "2022-08-07T04:51:44Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

作者： ![surfactant](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@surfactant](https://forum.freemdict.com/u/surfactant)\
发布日期： [2022 年8 月 9 日 16:48 UTC](https://forum.freemdict.com/t/topic/14514/19 "2022-08-09T16:48:22Z")

</div>

大概写了个脚本，可惜是 js的，跑了下还行，python好久不用忘差不多了，可以请python大神出手看看

```auto
content = "\r\n" + content + "\r\n"; // 当前文本文件的完整内容

var myEntry = ""; // 一个词头
var myContent = ""; // 一条释义

while (content.match(/\r\n@@@LINK=.+\r\n/) != null) {
   
      myEntry = content.match(/\r\n@@@LINK=.+\r\n/)[0];
      myEntry = myEntry.replace(/@@@LINK=/g, '');
      myEntry = myEntry.replace(/\r\n/g, '');
   
      myContent = content.match(RegExp('\r\n' + myEntry + '\r\n.+\r\n', ''))[0];
      myContent = myContent.replace(RegExp('\r\n' + myEntry + '\r\n', ''), '\r\n');

      content = content.replace(/\r\n@@@LINK=.+\r\n/, myContent);

} 

```

---

_[View the full topic](https://forum.freemdict.com/t/topic/14514)._
