1

Hi guys I really need some help, I need to do a mass replace expression in files I have a large list of urls which needs to be replaced.

I want to search files and replace each with the appropriate brand anchor link e.g.

http://www.example.com becomes

<a href=”http://www.example.com”&gt; http://www.example.com</a>

I need to do this with a large list of urls in multiple files

I tried the following expression (1)|(2)|(3) (?1a)(?2b)(?3c) But It doesn’t work. This is beyond me. Any help would be appreciated. Thanks

4

1 回答 1

2

转到Search > Replace菜单(快捷键CTRL+ H)并执行以下操作:

  1. 找什么:

    http:\/\/www\.\w+\.com
    
  2. 代替:

    <a href="$0">$0</a>
    
  3. 选择单选按钮“正则表达式”

  4. 然后按Replace All in All Opened Documents

您可以对其进行测试并在regex101中查看结果。

重要提示:使用正则表达式匹配 URL 可能很复杂!我给了你一个最简单的例子,它只匹配像http://www.example.com. 如果您有更复杂的东西,请告诉我们,但会显示您的一些数据!有关此问题的更多信息,请点击此处此处

更新

让我们也让它匹配起来稍微复杂一些 yoursite.com/index.php?remainingurl

找什么:

    (?:https?:\/\/)?(?:www\.)?(\w+\.\w{2,6})(?:\/\w+\.\w+(?:\?\w+)?)?\b

代替:

    <a href="$0">$1</a>
于 2013-11-12T18:45:14.173 回答