Search the Community
Showing results for tags 'vista search'.
-
WildcardMatch an Fast Filename Pattern Match (UDF) Machine Code Version (x32 and x64) Repeat the word from an C/C++ Writer { Introduction Simple wild card matching with ? and * is something that we use in our every day work just when opening a command prompt and using DIR and DEL. But how can this be done correctly in your program? OK, you can use regular expressions, and I recommend this when you already use a bunch of Boost, tr1 or STL stuff in your code. But sometimes, I like it easy and simple without tons of library code in the background. And because I saw a lot of wrong and in complex queries "wrong/failing" code, I just offer this small algorithm here. Background This wildcard matching function works just the same way as you expect and know it from the CMD.EXE DIR command. Using the Code The function just takes the string to check as a first argument and the mask with or without any wildcard characters as a second argument. It returns true if the strings match and false if not. It isn't spectacular. The characters ? and * are treated as wildcards. A ? character matches exactly one character and doesn't match an empty string. A * character matches any sequence of characters and an empty string too. Other characters are compared caseless. I use CharUpper and convert them to uppercase to perform this task. Feel free to use your own favorite way. Because * matches any character sequence and an empty string WildcardMatch(_T(""),_T("*")) returns true. } by Martin Richter, 28 Apr 2011 on codeproject.com AutoIt3 WildcardMatch No, I'm not doing any translation the C/C++ WildcardMatch to our favorite scripting language: AutoIt V3. Instead modificate thats source to be: - Ansi and Wide text version of WildcardMatch. - Portable and meet the condition to be used on Shell Code or Machine Code (That what Ward, trancexx and other called it!). And then write an UDF. UDF Name : CoreFx.Wildcard.au3 Functions : CoreFx_WildcardMatchExA($string, $patern) CoreFx_WildcardMatchExW($string, $patern) Includes : CoreFx.DynamicCode.au3 General.Imports.au3 WinAPI.Kernel32.au3 Platform : x32 and x64 bit Sample : $test.au3 . Download In Single ZIP (File Size: 5 KB. All required file are included). CoreFx.Wildcard.zip Sample $test.au3 Outputs: Ansi Test Empty string 1 CoreFx_WildcardMatchExA("", "*") Return 1 Empty string 2 CoreFx_WildcardMatchExA("", "") Return 1 Simple 1 CoreFx_WildcardMatchExA("MyName.doc", "*.DOC") Return 1 Simple 2 CoreFx_WildcardMatchExA("MyName.docx", "*.DOC") Return 0 Complex 1 CoreFx_WildcardMatchExA("MyNamName.docx", "My*Name.*x") Return 1 Complex 2 CoreFx_WildcardMatchExA("MyNamName.docx", "My*Name.*oc") Return 0 A CoreFx_WildcardMatchExA("filename.txt", "*.txt") Return 1 B CoreFx_WildcardMatchExA("filename.txt", "*.tx?") Return 1 C CoreFx_WildcardMatchExA("filename.txt", "file*name.txt") Return 1 D CoreFx_WildcardMatchExA("filename.txt", "fil*ame.txt") Return 1 E CoreFx_WildcardMatchExA("filename.txt", "f*l*a*e.*x?") Return 1 Wide Test Empty string 1 CoreFx_WildcardMatchExW("", "*") Return 1 Empty string 2 CoreFx_WildcardMatchExW("", "") Return 1 Simple 1 CoreFx_WildcardMatchExW("MyName.doc", "*.DOC") Return 1 Simple 2 CoreFx_WildcardMatchExW("MyName.docx", "*.DOC") Return 0 Complex 1 CoreFx_WildcardMatchExW("MyNamName.docx", "My*Name.*x") Return 1 Complex 2 CoreFx_WildcardMatchExW("MyNamName.docx", "My*Name.*oc") Return 0 A CoreFx_WildcardMatchExW("filename.txt", "*.txt") Return 1 B CoreFx_WildcardMatchExW("filename.txt", "*.tx?") Return 1 C CoreFx_WildcardMatchExW("filename.txt", "file*name.txt") Return 1 D CoreFx_WildcardMatchExW("filename.txt", "fil*ame.txt") Return 1 E CoreFx_WildcardMatchExW("filename.txt", "f*l*a*e.*x?") Return 1 . Source A Simple Wildcard Matching Function (Martin Richter [MVP C++]) Wikipedia Wildcard Character . For modified version of WildcardMatch (C++ source). If you need it, just pm me!
-
- Wildcard
- file pattern
- (and 5 more)