-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathWildcards2RegEx.ahk
38 lines (27 loc) · 905 Bytes
/
Wildcards2RegEx.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
; Title:
; Link: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=83453
; Author:
; Date:
; for: AHK_L
/*
#SingleInstance Force
strFiles := "abc.docx|abc.xlsx|def.docx|docx.txt"
strWildcards := "*.docx|abc.*|*b*.*|*.*x*|???.*|?b?.*o*|*c.*"
loop, parse, strWildcards, |
{
strWildCard := A_LoopField
strResult .= strWildCard . "`n"
loop, parse, strFiles, |
strResult .= A_LoopField . " -> " . (RegExMatch(A_LoopField, Wildcards2RegEx(strWildcard)) ? "yes" : "no") . "`n"
strResult .= "`n`n"
}
MsgBox, % strResult
return
*/
;---------------------------------------------------------
Wildcards2RegEx(strDosWildcards)
;---------------------------------------------------------
{
return "i)^\Q" . StrReplace(StrReplace(StrReplace(strDosWildcards, "\E", "\E\\E\Q"), "?", "\E.?\Q"), "*", "\E.*\Q") . "\E$"
}
;---------------------------------------------------------