繁体   English   中英

如何使用notepad ++一次替换另一个文件中的值

[英]How to use notepad++ to replace values from another file one at a time

我有一个文本文件(fileA),它具有相同的文本块100次(大约)

我还有一个文本文件(fileB),它具有100个(大约)值,每行一个。

我想搜索fileA,并且每次找到模式时,都将模式替换为fileB的下一行,即,将模式的第一次出现替换为fileB的第一行,将第二次出现替换为fileB的第二行,等等。

让我用伪代码编码要在Perl中执行的操作:

let subst_file = open(cmd-line arg 1) for reading, or exit with error
while line = line from stdin
  if pattern contained in line:
    replace_pattern = read next line from subst_file
    replace_line = regexp_replace(line, pattern, replace_pattern)
    output replace_line
  else:
    output line

其余部分留给他人或您自己的研究。 例如,perl中的while循环为: while (my $line = <STDIN>) { ... }

我在其他工具上搜索了一下此问题,并得出了答案。

Bash:将匹配的正则表达式替换为另一个文件的第n行

这对我有用,所以这就是我所追求的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM