![替換 Line 但保留部分內容在 Notepad ++ 中](https://rvso.com/image/1539542/%E6%9B%BF%E6%8F%9B%20Line%20%E4%BD%86%E4%BF%9D%E7%95%99%E9%83%A8%E5%88%86%E5%85%A7%E5%AE%B9%E5%9C%A8%20Notepad%20%2B%2B%20%E4%B8%AD.png)
我想使用 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};