AnsweredAssumed Answered

Regex: Split a number at the decimal point

Question asked by kelliganp on Apr 1, 2016
Latest reply on Apr 1, 2016 by kelliganp

Hi Folks,

 

I am working a problem where I need to evaluate the numbers on both sides of a decimal separately. I want to do some special rounding and since this cannot be done out of the box, I thought regex might be the answer. If I have a number like 125.32, I would like break it out into two numbers (125 and 32) the amount of digits on either side of the decimal point can vary.

 

15.5 split to 15;5

1254.32695 split to 1254;32695

.4 split to 0;4

 

bottom line, I want to evaluate the value right of the decimal and if it is <= .5 make it .5 and if is > .5, increase the integer on the left of the decimal by 1.

 

Any thoughts on the regex?

 

Thanks!

Patrick

Outcomes