Notepad ++在行尾添加文本,匹配两个字符串


-1

如果行开头NEW并包含/然后需要在结尾添加-reg

当前:

NEW  /RAM
VFXV RAM
NEW /TEST
SDFSDF
DSFDSF
NEW RAM

预期:

NEW  /RAM-reg
VFXV RAM
NEW /TEST-reg
SDFSDF
DSFDSF
NEW RAM

一行中有2个或更多斜杠怎么样,如:NEW /RAM /TEST
托托于

Answers:


0

这将匹配以NEW开头的所有行,并在行中的某处包含斜杠。

  • Ctrl+F
  • 找什么: ^NEW\b.*/.*\K$
  • 用。。。来代替: -reg
  • 检查包裹
  • 检查正则表达式
  • 不要检查 . matches newline
  • Replace all

说明:

^           : begining of string
  NEW\b     : literally "NEW", followed by a word boundary to not match NEWLY
  .*/.*     : at least a slash in the line
  \K        : forget all we have seen until this position
$           : end of string

给出示例的结果:

NEW  /RAM-reg
VFXV RAM
NEW /TEST-reg
SDFSDF
DSFDSF
NEW RAM
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.