Remove leading zeros from a Number given as a string | Function to remove all leading zeros from a a given string ; Regex to remove leading zeros from a string ; Replaces the matched value with given string ; Driver Code
function removeLeadingZeros ( str ) { const regex = new RegExp ( " " , ' ' ) ; str = str . replaceAll ( regex , " " ) ; document . write ( str ) ; } let str = " " ; removeLeadingZeros ( str ) ;