我正在使用 Notepad ++ 来编辑批处理脚本,我试图在每行上将2个文件夹名称附加到行的末尾,并使用"因为Folder2有时会有空格。 Folder1是日期,Folder2是名称。
要清楚我正在寻找一种方法在Notepad ++中执行此操作我想我可以使用RegEx查找和替换,但不知道正确的sytax或是否可以在Notepad ++中完成。
explexe "D:\I Drive\XY0\01022008\FIRST_LAST\0000\1.3.12.2.1107.5.1.4" "D:\I Drive\dump
explexe "D:\I Drive\XY0\01162008\FIRST,_LAST\0000\1.2.392.200036.912.2196110" "D:\I Drive\dump
explexe "D:\I Drive\XY0\04092008\FIRST_LAST___\0000\1.2.840.113680.5.1199306167.113468" "D:\I Drive\dump
我需要它看起来像这样。
explexe "D:\I Drive\XY0\01022008\FIRST_LAST\0000\1.3.12.2.1107.5.1.4" "D:\I Drive\dump\01022008\FIRST_LAST\"
explexe "D:\I Drive\XY0\01162008\FIRST,_LAST\0000\1.2.392.200036.912.2196110" "D:\I Drive\dump\01162008\FIRST,_LAST\"
explexe "D:\I Drive\XY0\04092008\FIRST_LAST___\0000\1.2.840.113680.5.1199306167.113468" "D:\I Drive\dump\04092008\FIRST_LAST___\"
我非常感谢任何帮助我是Notepad ++的新手!
答案 0 :(得分:0)
^.+?(\\\d{8})\\([^\\]+\\).+$
$0$1__$2"
<强>解释强>
^ : begining of line
.+? : 1 or more any character but newline, not greedy
( : start group 1
\\ : a backslash (must be escaped because it has special meaning in a regex)
\d{8} : 8 digits (I guess it is a date)
) : end group 1
\\ : a backslash
( : start group 2
[^\\]+ : 1 or more any character that is not a backslash
\\ : a backslash
) : end group 2
.+ : 1 or more any character but newline
$ : end of line
<强>替换强>
$0 : content of whole match, the entire line
$1 : content of group 1
__ : 2 underscores
$2 : content of group 2
" : literally double quote
. matches newline
给定示例的结果:
explexe "D:\I Drive\XY0\01022008\FIRST_LAST\0000\1.3.12.2.1107.5.1.4" "D:\I Drive\dump\01022008__FIRST_LAST\"
explexe "D:\I Drive\XY0\01162008\FIRST,_LAST\0000\1.2.392.200036.912.2196110" "D:\I Drive\dump\01162008__FIRST,_LAST\"
explexe "D:\I Drive\XY0\04092008\FIRST_LAST___\0000\1.2.840.113680.5.1199306167.113468" "D:\I Drive\dump\04092008__FIRST_LAST___\"