Advertisement
Java_Volume1 String Manipulation #92456

Wildcard Matcher

This code matches a given string against a pattern which may contain the well known wildcards * and ?, whereas * represents any number of characters, including none, and ? represents any single character. You may want to paste the code into a class module :)

AI

Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Codice sorgente
original-source
Public Function Match(Name As String, Pattern As String) As Boolean
  If MatchCase(LCase(Name), LCase(Pattern)) Then Match = True
End Function

Public Function MatchCase(Name As String, Pattern As String) As Boolean
  Pattern = PreparePattern(Pattern)
  If Name Like Pattern Then MatchCase = True
End Function
Private Function PreparePattern(Pattern As String) As String
  Pattern = Replace(Pattern, "[", "[[]")
  Pattern = Replace(Pattern, "#", "[#]")
  PreparePattern = Pattern
End Function
Commenti originali (3)
Recuperato da Wayback Machine