লিডিং জিরো রিমুভ করতে replace() মেথডে Regex ব্যবহার করুন:
yourStringValue.replace(/\D|^0+/g, "")
নম্বর ভ্যালুয়ের ভেরিয়েবল:
var theValue1 = "5001000"; var theValue2 = "100000005"; var theValue3 = "05000001"; var theValue4 = "00000000006456";
উদাহরণ
var theValue1 = "5001000"; var theValue2 = "100000005"; var theValue3 = "05000001"; var theValue4 = "00000000006456"; console.log(theValue1.replace(/\D|^0+/g, "")); console.log(theValue2.replace(/\D|^0+/g, "")); console.log(theValue3.replace(/\D|^0+/g, "")); console.log(theValue4.replace(/\D|^0+/g, ""));
রান কমান্ড: node fileName.js। ফাইল নাম demo101.js।
আউটপুট
PS C:\Users\Amit\JavaScript-code> node demo101.js 5001000 100000005 5000001 6456