Regex 如何在记事本+中替换文本并在该行末尾添加其他特定文本+;
我有一个包含以下文本的文件,例如:Regex 如何在记事本+中替换文本并在该行末尾添加其他特定文本+;,regex,notepad++,Regex,Notepad++,我有一个包含以下文本的文件,例如: the brown fox the red fox the brown cat 我想将“棕色”替换为“黄色”,并在行尾添加“已编辑”,以便文件内容如下: the yellow fox edited the red fox the yellow cat edited 请告诉我解决办法 感谢您的帮助。这需要分两步完成: Ctrl+H 第一步:使用正则表达式(确保在下面的搜索模式中切换“正则表达式”),查找句子是否包含brown,并将edited附加到句子末尾:
the brown fox
the red fox
the brown cat
我想将“棕色”替换为“黄色”,并在行尾添加“已编辑”,以便文件内容如下:
the yellow fox edited
the red fox
the yellow cat edited
请告诉我解决办法
感谢您的帮助。这需要分两步完成: Ctrl+H 第一步:使用正则表达式(确保在下面的搜索模式中切换“正则表达式”),查找句子是否包含brown,并将edited附加到句子末尾: 第二步很简单-将棕色替换为黄色
the yellow fox edited
the red fox
the yellow cat edited
这需要分两步完成: Ctrl+H 第一步:使用正则表达式(确保在下面的搜索模式中切换“正则表达式”),查找句子是否包含brown,并将edited附加到句子末尾: 第二步很简单-将棕色替换为黄色
the yellow fox edited
the red fox
the yellow cat edited
- Ctrl+H
- 查找内容:
\bbrown\b(+)$
- 替换为:
黄色$1已编辑
- 检查环绕
- 检查正则表达式
- 取消选中
。匹配换行符
- 全部替换
\bbrown\b # literally brown surround with word boundaries to avoid matching "brownies" or "whateverbrown"
(.+) # group 1, 1 or more any character but newline
$ # end of line
yellow # literally
$1 # content of group 1 (every thing after brown) followed by a space
edited # literally
更换:
\bbrown\b # literally brown surround with word boundaries to avoid matching "brownies" or "whateverbrown"
(.+) # group 1, 1 or more any character but newline
$ # end of line
yellow # literally
$1 # content of group 1 (every thing after brown) followed by a space
edited # literally
屏幕截图(之前):
\bbrown\b # literally brown surround with word boundaries to avoid matching "brownies" or "whateverbrown"
(.+) # group 1, 1 or more any character but newline
$ # end of line
yellow # literally
$1 # content of group 1 (every thing after brown) followed by a space
edited # literally
屏幕截图(之后):
\bbrown\b # literally brown surround with word boundaries to avoid matching "brownies" or "whateverbrown"
(.+) # group 1, 1 or more any character but newline
$ # end of line
yellow # literally
$1 # content of group 1 (every thing after brown) followed by a space
edited # literally
- Ctrl+H
- 查找内容:
\bbrown\b(+)$
- 替换为:
黄色$1已编辑
- 检查环绕
- 检查正则表达式
- 取消选中
。匹配换行符
- 全部替换
\bbrown\b # literally brown surround with word boundaries to avoid matching "brownies" or "whateverbrown"
(.+) # group 1, 1 or more any character but newline
$ # end of line
yellow # literally
$1 # content of group 1 (every thing after brown) followed by a space
edited # literally
更换:
\bbrown\b # literally brown surround with word boundaries to avoid matching "brownies" or "whateverbrown"
(.+) # group 1, 1 or more any character but newline
$ # end of line
yellow # literally
$1 # content of group 1 (every thing after brown) followed by a space
edited # literally
屏幕截图(之前):
\bbrown\b # literally brown surround with word boundaries to avoid matching "brownies" or "whateverbrown"
(.+) # group 1, 1 or more any character but newline
$ # end of line
yellow # literally
$1 # content of group 1 (every thing after brown) followed by a space
edited # literally
屏幕截图(之后):
\bbrown\b # literally brown surround with word boundaries to avoid matching "brownies" or "whateverbrown"
(.+) # group 1, 1 or more any character but newline
$ # end of line
yellow # literally
$1 # content of group 1 (every thing after brown) followed by a space
edited # literally
可能使用正则表达式?$匹配行的末尾。试试玩吧,我会试试的,谢谢你。也许用正则表达式?$匹配行的末尾。我会试试的,谢谢。这对我帮助很大!非常感谢。这对我帮助很大!非常感谢。