
编写一基于application的程序,读文件“test.txt”,统计其中英文字母的个数和大写字母的个数,并输出 20
2个回答
展开全部
又是用来交作业的吧?? 希望你能看一下,理解代码的意思,我就算没白写了.
<%
Dim fso, f1, re, rv, n1, n2
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.OpenTextFile(Server.MapPath("test.txt"), 1, true)
If Not(f1.AtenDOFStream) Then
Application.Lock
Application("content") = f1.ReadAll
Application.Unlock
End If
f1.Close
Set f1 = Nothing
Set fso = Nothing
Set re = New RegExp
re.Pattern = "[A-Z]"
re.Global = True
re.IgnoreCase = False
re.MultiLine = True
rv = re.Replace(Application("content"), "")
n1 = Len(Application("content")) - Len(rv)
re.Pattern = "[a-z]"
re.IgnoreCase = True
rv = re.Replace(Application("content"), "")
n2 = Len(Application("content")) - Len(rv)
Response.Write "test.txt文件中共有英文字母 " & n2 & " 个, 其中大写字母 " & n1 & " 个."
%>
<%
Dim fso, f1, re, rv, n1, n2
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.OpenTextFile(Server.MapPath("test.txt"), 1, true)
If Not(f1.AtenDOFStream) Then
Application.Lock
Application("content") = f1.ReadAll
Application.Unlock
End If
f1.Close
Set f1 = Nothing
Set fso = Nothing
Set re = New RegExp
re.Pattern = "[A-Z]"
re.Global = True
re.IgnoreCase = False
re.MultiLine = True
rv = re.Replace(Application("content"), "")
n1 = Len(Application("content")) - Len(rv)
re.Pattern = "[a-z]"
re.IgnoreCase = True
rv = re.Replace(Application("content"), "")
n2 = Len(Application("content")) - Len(rv)
Response.Write "test.txt文件中共有英文字母 " & n2 & " 个, 其中大写字母 " & n1 & " 个."
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询