微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

这是关于 Notepad++ 正则表达式替换

如何解决这是关于 Notepad++ 正则表达式替换

我想换

<th scope="col">@translate(Product)</th> 

代码

<th scope="col">{{trans("file.Product")}}</th> 

在 NotePad++ 中,但我无法编写完全正确的正则表达式。 请帮帮我。

解决方法

  • Ctrl+H
  • 查找内容:<th scope="col">\K@translate\((.+?)\)(?=</th>)
  • 替换为:{{trans("file.$1")}}
  • 检查 匹配案例
  • 检查 环绕
  • 检查 正则表达式
  • 全部替换

说明:

<th scope="col">        # literally
\K                      # forget all we have seen until this position
@translate              # literally
\(                      # openning parenthesis
(.+?)                   # group 1,1 or more any character,not greedy
\)                      # closing parenthesis
(?=</th>)               # positive lookahead,make sure we have a closing tag after

屏幕截图(之前):

enter image description here

屏幕截图(之后):

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。