I have a text document with raw links (not wrapped) and I would like to wrap them in HTML anchor tags.
Link example:
http://example.com/images/my-image.jpg
Desired output:
<a href="http://example.com/images/my-image.jpg">http://example.com/images/my-image.jpg</a>
I can FIND the links in Notepad++ using the following RegEx:
[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?(\?([-a-zA-Z0-9@:%_\+.~#?&//=]+)|)
However, the REPLACE string I'm trying is not working for some reason:
<a href="\1">\1</a>
中打包链接
如何使用notepad ++?
答案 0 :(得分:2)
您需要替换整个匹配的反向引用:
<a href="$&">$&</a>
或者
<a href="$0">$0</a>
此处,$0
和$&
&#34;插入&#34;与整个正则表达式匹配的文本,而不仅仅是某些捕获组。