Bueno, no me pude aguantar, aqui tienes LeandroA :
Me devuelve:
DoEvents¡!
Código (vb) [Seleccionar]
Option Explicit
Public Function IsInFilter(ByVal sText As String, ByVal sPatern As String) As Boolean
Dim oRegExp As Object
Dim oMatches As Object
Set oRegExp = CreateObject("VBScript.RegExp")
sText = " " & sText
sPatern = ReplaceFilter(sPatern)
With oRegExp
.Pattern = sPatern
.Global = True
.IgnoreCase = True
End With
Set oMatches = oRegExp.Execute(sText)
IsInFilter = CBool(oMatches.Count)
End Function
Public Function ReplaceFilter(ByVal sFilter As String) As String
Dim x As Integer
Dim n As Integer
Dim sActualChar As String
x = 1: n = 1
Do Until x > Len(sFilter)
sActualChar = Mid$(sFilter, x, 1)
If sActualChar = "?" Then
Do While Mid$(sFilter, x + 1, 1) = "?"
n = n + 1
x = x + 1
Loop
sActualChar = ".{" & n & "}"
n = 1
ElseIf sActualChar = "." Then
sActualChar = "\."
End If
ReplaceFilter = ReplaceFilter + sActualChar
x = x + 1
Loop
ReplaceFilter = Replace$(ReplaceFilter, "*", ".+")
ReplaceFilter = Replace$(ReplaceFilter, " ", "|")
If Left$(sFilter, 1) = "?" Then
ReplaceFilter = "(\s" & ReplaceFilter & ")"
Else
ReplaceFilter = "(" & ReplaceFilter & ")"
End If
End Function
' OffTopic : "Vivan las ranas¡!"
Private Sub Form_Load()
Debug.Print IsInFilter("holal.jpg", "?????.jpg") 'True
Debug.Print IsInFilter("a.jpg", "?.jpg") 'true
Debug.Print IsInFilter("foto.jpg", "*.jpg") 'True
Debug.Print IsInFilter("foto.jpg", "*.jpg *.bmp") 'True
Debug.Print IsInFilter("foto.bmp", "*.jpg *.bmp") 'True
Debug.Print IsInFilter("cualquiera.blend", "*.jpg *.bmp") 'False
' Los ejemplos que pusiste
Debug.Print IsInFilter("Azteca.bmp", "a?????.bmp") 'True
Debug.Print IsInFilter("Aztsdfdfdseca.bmp", "a?????.bmp") 'False
End Sub
Me devuelve:
Citar
Verdadero
Verdadero
Verdadero
Verdadero
Verdadero
Falso
Verdadero
Falso
DoEvents¡!