我没有做过很多服务器端脚本,但我有一些类似于你正在寻找的东西:
Function GetFileNames(Directory, Pattern)
Dim FileNames(), AfterPattern()
Dim FolderObject, fso, f
Dim i
i = 0
Set fso = CreateObject("Scripting.FileSystemObject")
Set FolderObject = fso.GetFolder(Directory)
ReDim FileNames(FolderObject.Files.Count)
ReDim AfterPattern(FolderObject.Files.Count)
For Each f In FolderObject.Files
FileNames(i) = f.Path
i = i + 1
Next
'Pattern Portion
Dim RegExp
Set RegExp = CreateObject("VBScript.RegExp")
RegExp.Pattern = Pattern
RegExp.Global = False
Dim x
x = -1
For i = LBound(FileNames()) To UBound(FileNames())
If RegExp.Test(FileNames(i)) = True Then
x = x + 1
AfterPattern(x) = FileNames(i)
End If
Next
ReDim Preserve AfterPattern(x+1)
GetFileNames = AfterPattern()
Set fso = Nothing
Set FolderObject = Nothing
Set RegExp = Nothing
End Function
第二个参数是您在问题中提到的正则表达式模式。:-)
干杯,LC