Extracting Letters from the String

  • Guys, Need to extract all the letters within the string , separated by comma. Now the code extracts first letters only. Please your help with modifying an user defined function:

    Code
    Function ExtractLetter(str As String)     Dim TDCode As String     Dim result As String          On Error GoTo ErrHandler:     With CreateObject("vbscript.regexp")         .Pattern = "[A-Z]+"         ExtractLetter = .Execute(str)(2)     End With     Exit Function ErrHandler: End Function

    Input: HKJ234CBV546LL Output (is): HKJ Output (ought): HKJ,CBV,LL

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!