我需要从一个结构化的.txt文件中复制regex匹配项,并将其粘贴到另一个类似的.txt文件中,以便从文件\u 1中找到的regex匹配项将用文件\u 1匹配项逐个替换文件\u 2中的相同匹配项?你知道吗
带有替换字符串的文本文件示例:
#TXT file 1:
randomtext_randomtext_randomtext_randomtext_new_STRING_Arandomtext_
randomtext_randomtext_new_STRING_Brandomtext_randomtext_randomtext_
randomtext_randomtext_randomtext_randomtext_randomtext_randomtext_
new_STRING_Crandomtext_randomtext_randomtext_randomtext_
#TXT file 2 (the exact same structure, but a little different strings values):
randomtext_randomtext_randomtext_randomtext_old_STRING_Arandomtext_
randomtext_randomtext_old_STRING_Brandomtext_randomtext_randomtext
_randomtext_randomtext_randomtext_randomtext_randomtext_randomtext_
old_STRING_Crandomtext_randomtext_randomtext_randomtext_
如何将使用regex找到的字符串:new \u STRING \u A、new \u STRING \u B和new \u STRING \u C从文件\u 1.txt复制到文件\u 2.txt中,以便使用相同的regex匹配:old \u STRING \u A、old \u STRING \u B、old \u STRING \u C,这样文件\u 1中的新字符串将替换文件\u 2中的旧字符串?你知道吗
不需要使用regex,只需要字符串比较函数
使用正则表达式
我有这样的东西,但它不起作用。我的目标是:
相关问题 更多 >
编程相关推荐