Page 1 of 1

Replacing a number with the first four digits

Posted: Sat Aug 08, 2015 2:50 am
by rodrigoef
Hello guys.

I have a list of numbers (geocoordinates) and the number of digits varies. I need to search the ones with more than four digits after the point and replace them with the first four digits only.

example: 48.655483275
I need to replace with 48.6554

I'm using [0-9]{5,}, and this found all the numbers with more than four digits after the point, but I'm failing in replace the number with the first four digits.

thanks

Re: Replacing a number with the first four digits

Posted: Tue Aug 11, 2015 8:52 am
by DigitalVolcano
This should work

Regex

Code: Select all

.([0-9]{4})[0-9]{1,}
Replace

Code: Select all

.$1
Try it in the regex tester

Re: Replacing a number with the first four digits

Posted: Thu Aug 27, 2015 10:16 am
by silentguy
DigitalVolcano wrote:This should work

Regex

Code: Select all

.([0-9]{4})[0-9]{1,}
Replace

Code: Select all

.$1
Try it in the regex tester
You forgot to escape the . ;-)