VPS business hosting starting at $29.95/24/7 premium technical support

Removing extra digits after decimal and leave only two decimal places

^(.*?\..?.?).*?$

your first match will leave the number with max 2 decimal digits.
So find with ^(.*?\..?.?).*?$ and replace with \1

Input

27485.0375
75777.9125
10785.0125
13822.5
26700
41194.375
9375
4354.225
11564.475
12430.1
3246.4875
11596.3375
22466.0375

Output:

27485.03
75777.91
10785.01
13822.5
26700
41194.37
9375
4354.22
11564.47
12430.1
3246.48
11596.33
22466.03

Author: Harshvardhan Malpani

PHP Developer based in New Delhi, India. Working as a freelance web developer providing server deployment, website development and maintenance services.

Leave a Reply

Your email address will not be published. Required fields are marked *