2

我目前有一长串代码如下:

<line fill="none" x1="555" y1="562.8181152" x2="542.1015625" y2="579.6394043"/>
<line fill="none" x1="542" y1="579.6394043" x2="527.46875" y2="594.4655762"/>
<line fill="none" x1="527.46875" y1="594.4655762" x2="504" y2="613.9626465"/>
<line fill="none" x1="504" y1="613.9626465" x2="481.9648438" y2="629.4460449"/>
<line fill="none" x1="481" y1="629.4460449" x2="461.6015625" y2="641.6647949"/>
<line fill="none" x1="461" y1="641.6647949" x2="441.1074219" y2="650.2966309"/>
<line fill="none" x1="441" y1="650.2966309" x2="424.0859375" y2="655.7995605"/>
<line fill="none" x1="424" y1="655.7995605" x2="394.5" y2="662.2321777"/>
<line fill="none" x1="394.5" y1="662.2321777" x2="368.8945313" y2="665.0407715"/>
<line fill="none" x1="368" y1="665.0407715" x2="351.0014648" y2="665.6970215"/>
<line fill="none" x1="351" y1="665.6970215" x2="332.1748047" y2="665.3688965"/>
<line fill="none" x1="332" y1="665.3688965" x2="311.1508789" y2="662.2321777"/>
<line fill="none" x1="311" y1="662.2321777" x2="287.7905273" y2="655.7995605"/>
<line fill="none" x1="287" y1="655.7995605" x2="267.5742188" y2="648.2351074"/>
<line fill="none" x1="267" y1="648.2351074" x2="243.965332" y2="636.6647949"/>
<line fill="none" x1="243.965332" y1="636.6647949" x2="216.9702148" y2="619.0388184"/>
<line fill="none" x1="216" y1="619.0388184" x2="194.0844727" y2="599.3747559"/>
<line fill="none" x1="194" y1="599.3747559" x2="171.9951172" y2="574.7194824"/>
<line fill="none" x1="171" y1="574.7194824" x2="153.3139648" y2="547.5153809"/>
<line fill="none" x1="153" y1="547.5153809" x2="137.4921875" y2="517.0036621"/>

由于这在移动设备上呈现为 svg,因此需要删除小数位,例如

<line fill="none" x1="153" y1="547" x2="137" y2="517"/>

代替

<line fill="none" x1="153" y1="547.5153809" x2="137.4921875" y2="517.0036621"/>

我知道这可以通过正则表达式实现,但是我在不同的示例中查看了 stackoverflow,但始终无法理解正则表达式。任何帮助表示赞赏!

4

2 回答 2

3

您可以使用以下正则表达式模式来获得所需的结果:

替换:\.(\d)*EMPTY STRING

为此,请转到“替换”选项卡并相应地将上述模式填写到“查找内容:”和“替换为”字段中。不要忘记单击“正则表达式”单选按钮。

于 2013-10-28T02:14:15.773 回答
2

为此,请转到Search-> Replace

Find: \.\d+
Replace:

输出

<line fill="none" x1="555" y1="562" x2="542" y2="579"/>
<line fill="none" x1="542" y1="579" x2="527" y2="594"/>
<line fill="none" x1="527" y1="594" x2="504" y2="613"/>
<line fill="none" x1="504" y1="613" x2="481" y2="629"/>
<line fill="none" x1="481" y1="629" x2="461" y2="641"/>
<line fill="none" x1="461" y1="641" x2="441" y2="650"/>
<line fill="none" x1="441" y1="650" x2="424" y2="655"/>
<line fill="none" x1="424" y1="655" x2="394" y2="662"/>
<line fill="none" x1="394" y1="662" x2="368" y2="665"/>
<line fill="none" x1="368" y1="665" x2="351" y2="665"/>
<line fill="none" x1="351" y1="665" x2="332" y2="665"/>
<line fill="none" x1="332" y1="665" x2="311" y2="662"/>
<line fill="none" x1="311" y1="662" x2="287" y2="655"/>
<line fill="none" x1="287" y1="655" x2="267" y2="648"/>
<line fill="none" x1="267" y1="648" x2="243" y2="636"/>
<line fill="none" x1="243" y1="636" x2="216" y2="619"/>
<line fill="none" x1="216" y1="619" x2="194" y2="599"/>
<line fill="none" x1="194" y1="599" x2="171" y2="574"/>
<line fill="none" x1="171" y1="574" x2="153" y2="547"/>
<line fill="none" x1="153" y1="547" x2="137" y2="517"/>
于 2013-10-28T02:30:05.337 回答