Windows 如何在记事本+;中自动将所有字符串的所有字段替换为trim(field_name)+;

Windows 如何在记事本+;中自动将所有字符串的所有字段替换为trim(field_name)+;,windows,notepad++,Windows,Notepad++,有一个文本文件包含 字符串, B日期, C字符串, D日期, E字符串, F日期, 等等 需要将所有字段替换为字符串,作为trim(字段名称) trim(A)字符串, B日期, 修剪(C)字符串, D日期, 修剪(E)字符串, F日期, 自动所有1000-10000行 Ctrl+H 查找内容:^(\w+(=\h+字符串) 替换为:trim\($1\) 检查环绕 检查正则表达式 全部替换 说明: ^ # beginning of line (\w+)

有一个文本文件包含

字符串,
B日期,
C字符串,
D日期,
E字符串,
F日期,
等等

需要将所有字段替换为
字符串
,作为
trim(字段名称)

trim(A)字符串,
B日期,
修剪(C)字符串,
D日期,
修剪(E)字符串,
F日期,

自动所有1000-10000行

  • Ctrl+H
  • 查找内容:
    ^(\w+(=\h+字符串)
  • 替换为:
    trim\($1\)
  • 检查环绕
  • 检查正则表达式
  • 全部替换
说明:

^               # beginning of line
  (\w+)         # group 1, 1 or more word character
  (?=           # positive lookahead, make sure we have after:
    \h+           # 1 or more horizontal spaces
    string        # literally "string"
  )             # end lookahead
trim        # literally
\(          # open parens, have to be escaped in Notepad++
  $1        # content of group 1
\)          # close parens, have to be escaped in Notepad++
更换:

^               # beginning of line
  (\w+)         # group 1, 1 or more word character
  (?=           # positive lookahead, make sure we have after:
    \h+           # 1 or more horizontal spaces
    string        # literally "string"
  )             # end lookahead
trim        # literally
\(          # open parens, have to be escaped in Notepad++
  $1        # content of group 1
\)          # close parens, have to be escaped in Notepad++
屏幕截图(之前):

^               # beginning of line
  (\w+)         # group 1, 1 or more word character
  (?=           # positive lookahead, make sure we have after:
    \h+           # 1 or more horizontal spaces
    string        # literally "string"
  )             # end lookahead
trim        # literally
\(          # open parens, have to be escaped in Notepad++
  $1        # content of group 1
\)          # close parens, have to be escaped in Notepad++

屏幕截图(之后):

^               # beginning of line
  (\w+)         # group 1, 1 or more word character
  (?=           # positive lookahead, make sure we have after:
    \h+           # 1 or more horizontal spaces
    string        # literally "string"
  )             # end lookahead
trim        # literally
\(          # open parens, have to be escaped in Notepad++
  $1        # content of group 1
\)          # close parens, have to be escaped in Notepad++

为什么需要记事本++?请尝试
sed的/\(.[^]\)*\(字符串,\)$/trim(\1)\2/'inputfile>outputfile
当前我正在使用Windows请参见