asp检查文本文件是否包含特定文本

2024-11-09阅读:2513

asp如何检测文本文件是否包含指定的文本内容,我们编写一个检查的函数,如下:

Function isStringInFile(fileFullPath, PatternString)
Set objFSO = CreateObject("Scripting.FileSystemObject")
set re = New RegExp
strContents = readAllFromFile(objFSO,fileFullPath)
re.IgnoreCase = True
re.Pattern = PatternString
isStringInFile = re.test(strContents)
set objFSO = Nothing
End Function

fileFullPath代表文本路径。

PatternString代表特定的文本。


大家都爱看
查看更多热点文章