Regular: how to match content after 2 decimal places

// 2

var s = "12.34567"     
//  12.34
console.log(s.replace(/\.\d{2}/, "*")) // 12*567
console.log(s.replace(/\.[^\d]{2}\d+/, "*")) // 12.34567

var s = '12.34567';
var num = Number (s.match (/ ^ d + (?: .d {0jue 2})? /)
alert (num); / / 12.34

rounding:
var s = 12.34567
alert (s.toFixed (2)); / / 12.35

)
/^(\d+\.\d{2})(\d+)$/.test(12.34567)
true
RegExp.$2
"567"

clipboard.png


1. No regularization

new Number('12.34567').toFixed(2);
(+'12.34567').toFixed(2);
var s='12.34567';
s.substring(0,s.indexOf(".")+3);

II. Use regularization

'12.34567'.match(/^\d+\.\d{2}/)[0];
'12.34567'.replace(/^(\d+\.\d{2})\d*$/,"$1");
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea61a6-1dab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea61a6-1dab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?