在记事本++中切换单词位置 [英] Switch word postions in Notepad ++

查看:121
本文介绍了在记事本++中切换单词位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的文字如下:

Text1 | Text2 | Text3 | Text4 | Text5 | Text6 | Text7 

我想更改文本位置

Text1 | Text4 | Text5 | Text6 | Text2| Text3 | Text7 

如果可以在文本4、5、6之间删除|,使其看起来像

And if it's possible to remove the | between Text 4, 5, 6, so that it looks like

Text1 | Text4 Text5 Text6 | Text2 | Text3 | Text7

如果不可能,如果第一个问题解决了,我将感到高兴.

If it is not possible, I'll be happy if the first problem is solved.

推荐答案

您可以使用

^([^|]*\|)((?:[^|]*\|){2})((?:[^|]*\|){3})

并替换为$1$3$2.

详细信息:

  • ^-一行的开头
  • ([^|]*\|)-组1($1)捕获除|以外的零个或多个字符,然后捕获文字|
  • ((?:[^|]*\|){2})-第2组($2)捕获与第1组相同模式的2个序列
  • ((?:[^|]*\|){3})-第3组($3)捕获与第1组相同模式的2个序列
  • ^ - start of a line
  • ([^|]*\|) - Group 1 ($1) capturing zero or more chars other than | and then a literal |
  • ((?:[^|]*\|){2}) - Group 2 ($2) capturing 2 sequences of the same pattern as in Group 1
  • ((?:[^|]*\|){3}) - Group 3 ($3) capturing 2 sequences of the same pattern as in Group 1

在替换模式中,顺序将根据反向引用的顺序进行更改.

The order is changed with the order of the backreferences in the replacement pattern.

要删除第二,第三和第四|,请使用类似的表达式:

To remove the 2nd, 3rd and 4th |, use a similar expression:

查找内容:^([^|]*\|)([^|]*)\|([^|]*)\|([^|]*)
替换为:$1$2$3$4

Find what: ^([^|]*\|)([^|]*)\|([^|]*)\|([^|]*)
Replace with: $1$2$3$4

基本上,您只需要在替换模式中操作捕获组的边界和反向引用的顺序即可.

Basically, you just manipulate the capturing group boudaries and the order of the backreferences in the replacement pattern, that is all.

这篇关于在记事本++中切换单词位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆