在 Notepad++ 中查找并替换匹配的行首和行尾

Find and replace in Notepad++ matching beginning and end of line

我想查找所有遵循这种格式的行:

type="file_one_id"
type="file_two_id"
type="file_three_id"

并用单个替换行替换它们:

type="my_generic_replacement"

问题是还有许多其他行也以 type="file_ 开头或以 _id" 结尾,所以我想搜索都以 type="file_ 开头的行需要 _id" 结尾。有没有办法用记事本++做到这一点?

您可以搜索 ^type="file_.*_id"$(使用正则表达式)并替换为 type="my_generic_replacement"

要替换 Notepad++ 中的行,您可以使用此正则表达式:

type="file_\w+_id"

要打开 window 单击搜索 => 替换

您可以找到并替换\r\n并在替换框中勾选扩展; \r\n 匹配 carriage-return + line-feed。 某些系统可能只有 \r 或只有 \n 在换行符