Reputation: 69
Well the title says it all.I would like to find a regex that allows me to match the remaining decimals after the 4 first decimals. For the moment I've figured out how to match the number and the 4 first decimals.
^\d+\.\d{0,4}$
but it's the remaining figures that I would like to match on negative and positive numbers.
45.46867431 ---> returns 7431.
5.34 ---> returns nothing.
0.0015 ---> returns nothing.
-135.6584312315 ---> returns 312315.
0.008951 returns ---> returns 51.
I need it to be a regex because it's to clean files, not to format it direclty with a script.
Upvotes: 0
Views: 97
Reputation: 39355
This will return you the digits after the dot and four digits.
^-?\d+\.\d{4}(\d+)$
Assuming there will be no input like .102123
Upvotes: 0
Reputation: 11116
(?<=\.\d{4})\d+
this should do the trick.
demo here : http://regex101.com/r/eW8fR6
Upvotes: 2