我正在尝试使用 Notepad++ 解析一些 svg 坐标。我想获取每一层的坐标集并将坐标放在 [] 内,以使其准备好在 javascript 数组中使用。
svg 文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="800px"
height="900px" viewBox="0 0 800 900" enable-background="new 0 0 800 900" xml:space="preserve">
<g id="Layer_3">
<polyline fill="none" stroke="#0000FF" stroke-width="3" points="33,108 66,141 99,174 99,207 132,207 165,207 165,240 "/>
</g>
<g id="Layer_4">
<polyline fill="none" stroke="#0000FF" stroke-width="3" points="132,306 165,306 165,339 165,372 132,405 99,405 99,438 132,438
165,438 "/>
</g>
<g id="Layer_5">
<polyline fill="none" stroke="#0000FF" stroke-width="3" points="198,339 231,339 264,372 297,372 330,405 363,438 396,438 "/>
</g>
<g id="Layer_6">
<polyline fill="none" stroke="#0000FF" stroke-width="3" points="198,174 198,273 231,306 264,306 "/>
</g>
<g id="Layer_7">
<polyline fill="none" stroke="#0000FF" stroke-width="3" points="231,174 231,240 264,273 297,273 "/>
</g>
<g id="Layer_9">
<polyline fill="none" stroke="#0000FF" stroke-width="3" points="396,306 462,306 495,339 495,372 528,405 528,438 561,438
594,471 "/>
</g>
<g id="Layer_10">
<polyline fill="none" stroke="#0000FF" stroke-width="3" points="660,504 561,504 495,504 "/>
</g>
</svg>
我希望结果看起来像这样:
[33,108 66,141 99,174 99,207 132,207 165,207 165,240]
[132,306 165,306 165,339 165,372 132,405 99,405 99,438 132,438 165,438]
[198,339 231,339 264,372 297,372 330,405 363,438 396,438]
[198,174 198,273 231,306 264,306]
[231,174 231,240 264,273 297,273]
[396,306 462,306 495,339 495,372 528,405 528,438 561,438 594,471]
[660,504 561,504 495,504]
我对正则表达式很陌生,但这是我微弱的尝试:
搜索:.+points="(.+")
替换为:[$1]
我被卡住了,因为搜索部分似乎没有搜索“点”字符串上方的行。即使文档中的垃圾要高得多,我怎样才能摆脱除坐标之外的所有内容?