使用notepad ++查找和替换使用通配符的文本

时间:2014-09-08 18:19:54

标签: regex

您好我正在尝试使用通配符在notepad ++中查找和替换文本以替换引号内的内容。例如,我需要能够找到<a href="http://example.com/wp-content/2014/09/08/hello-world.jpg">并替换为<a href="http://example.com/2014/09/08/hello-world/1/">。我试过<a href=" * ">,但它说没有找到任何东西..

有人可以帮我搞清楚..

提前致谢

1 个答案:

答案 0 :(得分:3)

您的正则表达式会查找空格字符&#34;零或更多&#34;时间和尾随空间。如果要替换引号之间的全部内容,请捕获标记的第一部分和最后部分,并仅替换中间部分。

Find: (<a href=")[^"]*(">)
Replace: \1replacement\2

这个正则表达式说:

(            # group and capture to \1:
 <a href="   #   '<a href="'
)            # end of \1
 [^"]*       #   any character except: '"' (0 or more times)
(            # group and capture to \2:
 ">          #   '">'
)            # end of \2