Notepad++ 记事本++;如何使用正则表达式复制text\folder1\folder2\并附加到行尾?

Notepad++ 记事本++;如何使用正则表达式复制text\folder1\folder2\并附加到行尾?,notepad++,Notepad++,我正在使用记事本+++编辑一个批处理脚本,在该脚本中,我试图将每行上的两个文件夹名称附加到一个“因为Folder2有时有空格。Folder1是日期,Folder2是名称 为了明确起见,我正在寻找一种在Notepad++中实现这一点的方法,我认为我可以使用Find并替换为RegEx,但不知道正确的sytax,或者它是否可以在Notepad++中实现 explexe "D:\I Drive\XY0\01022008\FIRST_LAST\0000\1.3.12.2.1107.5.1.4" "D:\I

我正在使用记事本+++编辑一个批处理脚本,在该脚本中,我试图将每行上的两个文件夹名称附加到一个“因为Folder2有时有空格。Folder1是日期,Folder2是名称

为了明确起见,我正在寻找一种在Notepad++中实现这一点的方法,我认为我可以使用Find并替换为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___\"
如果有任何帮助,我将不胜感激。我是记事本++!

  • Ctrl+H
  • 查找内容:
    ^.+?(\\\d{8})\\([^\\]+\\)。+$
  • 替换为:
    $0$1\uuu$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
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___\"
更换:

^           : 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
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___\"
  • 检查环绕
  • 检查正则表达式
  • 不要选中
    。匹配换行符
给定示例的结果:

^           : 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
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++中执行此操作,因为我正在使用它编辑脚本。这不是一个脚本问题。。。也许这可以通过编写脚本来解决,我并不真正关心这一点,我想知道如何在Notepad++中执行上述操作。OP正在尝试使用Notepad++替换他们正在编辑的批处理文件中的文本。这不是关于如何在Windows批处理文件中执行某些操作的问题。谢谢!这将有很大帮助,因为有81828行需要编辑,还有5个驱动器需要编辑,行数也差不多。你帮了大忙,谢谢@RickFn:请随意将答案标记为已接受,请参阅:而不是像这样将2个目录追加到行的末尾。D:\I Drive\dump\01022008\FIRST\u LAST\“我可以像这样将这两个目录合并起来吗?D:\I Drive\dump\01022008\u FIRST\u LAST\”