[Solved] VB.net get date from string [closed]


@Pᴇʜ Regex pattern shared in the comment works perfectly per your examples. Here is how to use it with an in cell function.

Don’t Forget to add the reference to “Microsoft VBScript Regular Expressions 5.5

Function simpleCellRegex(Myrange As Range) As String
    Dim regEx As New RegExp
    Dim strPattern As String
    Dim strInput As String
    Dim strOutput As String
    Dim matches As Object

    strPattern = "(?:January|Februrary|March|April|May|June|July|August|September|October|November|December) [0-9]{1,2}, [0-9]{4}|[0-9]{1,2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{2,4}|[0-9]{1,2}.[0-9]{1,2}.[0-9]{2,4}"

    If strPattern <> "" Then
        strInput = Myrange.Value

        With regEx
            .Global = True
            .MultiLine = True
            .IgnoreCase = False
            .Pattern = strPattern
        End With

        If regEx.Test(strInput) Then
            Set matches = regEx.Execute(strInput)
            If matches.Count <> 0 Then simpleCellRegex = matches.Item(0)
        Else
            simpleCellRegex = "Not matched"
        End If
    End If
End Function

Input is in column A and column B uses formula =simpleCellRegex(A1)

Tested

enter image description here

1

solved VB.net get date from string [closed]