<P1 x="-0,36935" y="0,26315"/><P2 x="4,29731" y="0,26315"/><P3 x="5,29731" y="-0,40351"/><P4 x="-0,36935" y="-0,40351"/>
<P1 x="4,64065" y="0,26315"/><P2 x="5,97398" y="0,26315"/><P3 x="5,30731" y="-0,40351"/><P4 x="4,64065" y="-0,40351"/>
我想將 P3(x) 的值放入 P2(x)。
到目前為止,我有一個有點可行的解決方案,這不是最漂亮的;
((?:P2 x=\")(.*?[^\"] )(?=. ((?:P3 x=\")(.*?[^\"] ))))
它迫使我使用P2 x="\4替換而不是簡單地\4

uj5u.com熱心網友回復:
你可以試試這個正則運算式:
(?<=<P2 x=")[\d,-] (?=.*<P3 x="([\d,-] )")
代換:
\1
(?<=<P2 x=") // positive lookbehind, the following rule must be preceded by <P2 x="
[\d,-] // a set of characters formed by digits, comma and -
(?=.*<P3 x="([\d,-] )) // positive lookahead, find the x value of P3 and store it in group 1
看證明
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/355940.html
上一篇:Pythonre.findall不匹配HTML中的JS變數
下一篇:多個拆分條件
