用正则表达式实现替换 80
是否可以将下面的代码“需要替换的内容”改成正则表达式识别?SetWshShell=CreateObject("Wscript.Shell")WshShell.Run"cm...
是否可以将下面的代码“需要替换的内容”改成正则表达式识别?
Set WshShell = CreateObject("Wscript.Shell")
WshShell.Run "cmd /c dir /s/b *.htm > list.htm",vbHide
Wscript.Sleep 1000
sFile = "list.htm"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = objFSO.OpenTextFile(sFile,1)
Do While Not oFile.AtEndOfStream
strLine = oFile.ReadLine
If Len(strLine) > 0 Then
Set File = objFSO.OpenTextFile(strLine, 1)
aryLines = File.ReadAll
File.Close
aryLines = Replace(aryLines, "需要替换的内容", "替换后的内容")
Set File = objFSO.OpenTextFile(strLine, 2)
File.Write aryLines
File.Close
End If
Loop
oFile.Close
objFSO.DeleteFile sFile
Set objFSO = Nothing 展开
Set WshShell = CreateObject("Wscript.Shell")
WshShell.Run "cmd /c dir /s/b *.htm > list.htm",vbHide
Wscript.Sleep 1000
sFile = "list.htm"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = objFSO.OpenTextFile(sFile,1)
Do While Not oFile.AtEndOfStream
strLine = oFile.ReadLine
If Len(strLine) > 0 Then
Set File = objFSO.OpenTextFile(strLine, 1)
aryLines = File.ReadAll
File.Close
aryLines = Replace(aryLines, "需要替换的内容", "替换后的内容")
Set File = objFSO.OpenTextFile(strLine, 2)
File.Write aryLines
File.Close
End If
Loop
oFile.Close
objFSO.DeleteFile sFile
Set objFSO = Nothing 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询