我想使用 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};