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
Replacing a number with the first four digits
- DigitalVolcano
- Site Admin
- Posts: 1863
- Joined: Thu Jun 09, 2011 10:04 am
Re: Replacing a number with the first four digits
This should work
Regex
Replace
Try it in the regex tester
Regex
Code: Select all
.([0-9]{4})[0-9]{1,}
Code: Select all
.$1
Re: Replacing a number with the first four digits
You forgot to escape the . ;-)DigitalVolcano wrote:This should work
RegexReplaceCode: Select all
.([0-9]{4})[0-9]{1,}
Try it in the regex testerCode: Select all
.$1