将第二行移至第三行//记事本++

时间:2018-03-14 10:54:14

标签: excel excel-vba notepad++ vba

我有以下txt文件包含一行三行并重复(总共4000行):

Printer1
/900
HBA/8/7
Printer2
/800
HBA/7/2

现在我想将第二行移动到第三行的末尾,然后重复(第5行到第6行;第8行到第9行结束,依此类推)

用记事本++可以做到这一点吗?或者Excel宏?我找到了一些regex和vmi的例子,但问题是他们正在寻找关键字。我只想让整个第二行移到第三行结束......然后继续模式(第5->第6;第8->第9行)

非常感谢任何输入/想法/解决方案。

亲切的问候

米奇

2 个答案:

答案 0 :(得分:0)

好吧,有时候会有一些时间带来想法:)

我刚刚在Excel中导入了txt文件,因此第1行是“Printer1”,第2行是“/ 900”,依此类推。 然后我就这样做了:

B1 =A1
B2 =A3&A2
B3 =empty

然后我只是将B1标记为B3并用按下的ctrl键拖动它直到文件结束。 Etvoilà我有我需要的东西。现在我只将B列复制到新的txt文件中,一切都很好:)

答案 1 :(得分:0)

  • 控制 + ħ
  • 找到:^.+\R\K(.+\R)(.+\R)
  • 替换为:$2$1
  • 检查环绕
  • 检查正则表达式
  • 请勿检查. matches newline
  • 全部替换

<强>解释

^           : beginning of line
  .+        : 1 or more any character but newline (ie. the first line)
  \K        : forget all we have seen until this position
  (.+\R)    : Group 1, 1 or more any character followed by linebreak (ie. the second line)
  (.+\R)    : Group 2, 1 or more any character followed by linebreak (ie. the third line)

<强>替换

$2      : content of group 2
$1      : content of group 1

给定示例的结果:

Printer1
HBA/8/7
/900
Printer2
HBA/7/2
/800
相关问题