Notepad++ Remove Decimal Places

Tag: regex , notepad++ Author: honganan123 Date: 2013-10-11

I currently have a long list of code as follows:

<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"/>

Due to this being rendered on mobile devices as a svg this needs to remove the decimal places leaving it with for example

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

instead of

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

I know this is possible via regular expression however I've looked around developark at different examples but could never get my head around regular expression. Any help is appreciated!

Best Answer

You can use the following regex patterns to obtain the desired result:

Replace: \.(\d)* with EMPTY STRING

To do that, go to "Replace" tab and fill in the above patterns into "Find what:" and "Replace with" fields accordingly. Don't forget to click on "Regular expression" radio button.

Other Answer1

To do this, goto Search -> Replace.

Find: \.\d+
Replace:

Output

<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"/>