notepad++ 正则表达式搜索和替换

notepad++ 正则表达式搜索和替换

我试图从中得到:

1200        PORTAL  oracle  29489   17:57   48 username cell single block physical read 2

更改为:

EXEC SYS.KILLSID (1200,29489,2)

 

答案1

find ^(\d{1,4}) [^\d]\*(\d{4,5}) .*(\d)$
replace EXEC SYS.KILLSID (\1,\2,\3)

答案2

  • Ctrl+H
  • 找什么:^(\d{1,4})\D+(\d{4,5}).+(\d)$
  • 用。。。来代替:EXEC SYS.KILLSID \($1,$2,$3\)
  • 检查环绕
  • 检查正则表达式
  • 请勿检查. matches newline
  • Replace all

解释:

^           : begining of line
  (\d{1,4}) : group 1, 1 to 4 digits
  \D+       : 1 or more non digits
  (\d{4,5}) : group 2, 4 or 5 digits
  .+        : 1 or more any character but newline
  (\d)      : group 3, 1 digit
$           : end of line

替代品:

EXEC SYS.KILLSID    : literally
\(                  : open parenthesis, in Npp, it has to be escaped
  $1                : content of group 1
  ,                 : a comma
  $2                : content of group 2
  ,                 : a comma
  $3                : content of group 3
\(                  : close parenthesis, in Npp, it has to be escaped

给定示例的结果:

EXEC SYS.KILLSID (1200,29489,2)

相关内容