记事本++正则表达式搜索和替换


1

我想从中得到:

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

对此:

EXEC SYS.KILLSID (1200,29489,2)


第一个数字(1200)也可以是1到4位数的任何数字。第二个数字(29489)的某些东西可能是4到5位长,最后一个数字(2)总是1位数长。
redninam

Answers:


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

1
  • 按Ctrl + H
  • 找什么: ^(\d{1,4})\D+(\d{4,5}).+(\d)$
  • 用。。。来代替: EXEC SYS.KILLSID \($1,$2,$3\)
  • 检查包裹
  • 检查正则表达式
  • 不要检查 . matches newline
  • 全部替换

说明:

^           : 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)
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.