Sub WildCardFilesList2(FilesPath As String, WildCards As String, Sorted As Boolean, Ascending As Boolean) As List
If File.IsDirectory("", FilesPath) Then
Dim FilesFound As List = File.ListFiles(FilesPath)
Dim GetCards() As String = Regex.Split(",", WildCards)
Dim FilteredFiles As List : FilteredFiles.Initialize
For i = 0 To FilesFound.Size -1
For l = 0 To GetCards.Length -1
Dim TestItem As String = FilesFound.Get(i)
Dim mask As String = GetCards(l).Trim
Dim pattern As String = "^"&mask.Replace(".","\.").Replace("*",".+").Replace("?",".")&"$"
If Regex.IsMatch(pattern,TestItem) = True Then
FilteredFiles.Add(TestItem.Trim)
End If
Next
Next
If Sorted Then
FilteredFiles.SortCaseInsensitive(Ascending)
End If
Return FilteredFiles
Else
Msgbox("You must pass a valid Directory.", "NOTICE")
End If
End Sub