2011-09-13

VBA - Remove string leading zeroes using a regular expression


Public Function fStringLeadingZeros(str As String) As String

    Dim re As Object
    Set re = CreateObject("VBScript.RegExp")
    re.pattern = "^0+"
    fStringLeadingZeros = re.Replace(str, "")
    Set re = Nothing

End Function

No comments:

Post a Comment