简体   繁体   English

Notepad ++ 使用正则表达式切换位置

[英]Notepad++ switch postions with regex

Hello I need a help with my text which is like this你好,我需要帮助我的文字是这样的

Text1|Text2|Text3|Text4|Text5|Text6|Text7|Text8|Text9|Text10文本1|文本2|文本3|文本4|文本5|文本6|文本7|文本8|文本9|文本10

So the text need to change it to like this:所以文字需要改成这样:

Text8|Text5|Text4|Text9|Text10|Text7文本8|文本5|文本4|文本9|文本10|文本7

So change these texts postions and remove Text 1,2,3,6因此,更改这些文本位置并删除文本 1、2、3、6

With regex you can use capture groups to replace stuff.使用正则表达式,您可以使用捕获组来替换内容。 In your case it might look like在你的情况下,它可能看起来像

find

(Text1)\|(Text2)\|(Text3)\|(Text4)

replace代替

$2|$1|$4|$3

will result in会导致

Text2|Text1|Text4|Text3

So just apply this technique to your longer string and it should work just fine.因此,只需将此技术应用于较长的字符串,它应该可以正常工作。 Assuming you know how to order the results.假设您知道如何对结果进行排序。

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

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