我想使用 Notepad++ 查找/替换大块代码:
我有很多:
角度[] = {6.2744589,5.4066987,1.4066987};
有 3 个值。我需要将所有第一个和第二个值都设置为 0,并保留第三个位置的值 :S
角度[] = {6.2744589,5.4066987,1.4066987};
到
角度[] = {0,0,1.4066987};
谢谢!
答案1
答案2
- Ctrl+H
- 找什么:
\bangles\[\]=\{\K[^,]+,[^,]+
- 用。。。来代替:
0,0
- Replace all
解释:
\b : word boundary, to be sure to match angles but not somethingangles
angles : literally angles
\[\]=\{ : literally []=, brackets have to be escaped as they have special meaning in regex
\K : Forget all we have seen until this point
[^,]+ : 1 or more any character that is not a comma, that matches also negative values
, : a comma
[^,]+ : 1 or more any character that is not a comma
- 检查正则表达式
- 请勿检查
. matches newline
给定示例的结果:
angles[]={0,0,1.4066987};