Untitled

mail@pastecode.io avatar
unknown
vbscript
22 days ago
666 B
3
Indexable
Never
Function ExtractPart(str As String) As String
    Dim regex As Object
    Dim matches As Object
    Dim match As Object
    
    ' Create the regex object
    Set regex = CreateObject("VBScript.RegExp")
    
    ' Set the regex pattern to find AU-xxxxxx-x format
    regex.Pattern = "AU-\d+-\d"
    regex.Global = True
    
    ' Find matches
    Set matches = regex.Execute(str)
    
    ' Check if there is at least one match
    If matches.Count > 0 Then
        ' Return the first match
        ExtractPart = matches(0).Value
    Else
        ' Return an empty string if no match is found
        ExtractPart = ""
    End If
End Function
Leave a Comment