Knowledge Base: Examples of Recursion โRecursively Removal of Multiple Spaces by Using VBScript
Knowledge Base: Examples of Recursion
Recursion: each item of an expression is generated by repeating a particular definition recursively.
Recursively Removal of Multiple Spaces by Using VBScript
Example of Recursively Removal of Multiple Spaces by Using VBScript.last updated 01Sep2017
ASP VbScript Command:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sample Page</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<%Dim strs
strs="<!DOCTYPE html>" & vbCrLf & _
"<html lang=""en"">"
Response.Write prtwoctrl("Sample Display: """&strs&"""")
Response.Write prtwoctrl("Sample Storage: """&replace(strs," ","%20")&"""")
Call prtwoctrl("Start Removal of Multiple Spaces")
Call rmv_gap(strs)
Call prtwoctrl("End of Recursion")
%>
<script language = "vbscript" runat = "server">
Function rmv_gap(blk_str)
Dim a,b,c,d
a= split(blk_str,"<",2)
Select Case ubound(a)
Case 1, "1"
b=split(a(1),">",2)
c=split(b(0)," ",2)
Select Case lcase(c(0))
Case "!doctype"
rmv_gap="<"&c(0)&">"
End Select
Case Else
rmv_gap=a(0)
End Select
Call prtwoctrl(""""&rmv_gap&"""")
End Function
Function prtwoctrl(blk_str)
Dim temp_blk_str
temp_blk_str=Replace(Replace(Replace(Replace(Replace(blk_str,"&","&"),"<","<"),"""","""),">",">"),"%20"," ")&"<br />"
Response.Write temp_blk_str
End Function
Function rmvspace(blk_str)
Dim a,b,c
a= split(blk_str," ",2)
If ubound(a)=1 Then
c=ltrim(a(1))
Select Case c
Case ""," ",null
b= a(0)&" "
Case Else
b= a(0)&" "& rmvspace(c)
End Select
Else
b=a(0)
End IF
rmvspace=b
Response.Write """&b&"""&"<br />"
End Function
</script>
</body>
</html>
HTTP Response Output:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sample Page</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
Sample Display: "<!DOCTYPE html>
<html lang="en">"<br />Sample Storage: "<!DOCTYPE html>
<html lang="en">"<br />Start Removal of Multiple Spaces<br />"<!DOCTYPE>"<br />End of Recursion<br />
</body>
</html>
HTML Web Page Embedded Output:
ยฉsideway
ID: 180300008 Last Updated: 3/8/2018 Revision: 0 Ref:
References
Active Server Pages, โ, http://msdn.microsoft.com/en-us/library/aa286483.aspx
ASP Overview, โ, http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx
ASP Best Practices, โ, http://technet.microsoft.com/en-us/library/cc939157.aspx
ASP Built-in Objects, โ, http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx