方法一:
<%
content="第乙個標籤,兩個引數選擇顯示型別和顯示條數
$shownews(2,15)$第二個標籤,乙個引數來判斷拆分的有效性,$show2(5)$
第三個標籤,無引數$nolable()$"
'這是我習慣用的變數名,從模板讀取的內容變數.
call replacelable(content,"$shownews")
call replacelable(content,"$show2")
call replacelable(content,"$nolable")
'這裡呼叫處理標籤的程式,可以適用不同的標籤,注意寫法!
response.write content
'顯示處理過的內容
sub replacelable(c,l)
'這個sub說過用途了!
tmp2=1
while instr(tmp2,c,l)>0
'一開始沒想明白這個迴圈的作用,後來想想要看是否有多個標籤,比較深刻
tmp1=instr(tmp2,c,l)'標籤第一位
tmp2=instr(tmp1+1,c,"$")'標籤結束.
tmpstr=mid(c,tmp1,tmp2-tmp1)'標籤除}部分.
tmpstr=replace(tmpstr,l,"")'去除$shownews,即剩下引數(2,15)
tmpstr=replace(tmpstr,"(","")
tmpstr=replace(tmpstr,")","")'只剩下2,15
canshu=split(tmpstr,",")
'這裡將引數拆分,不管多少個,要在下面的select中分別處理,看來還要試一下無引數和乙個引數的才能穩定
'測試結果,對於沒有引數的標籤要加()才行,使用時注意就可以了
select case l
case "$shownews"
c=replace(c,l&"("&tmpstr&")$",author(canshu(0),canshu(1)))
case "$show2"
c=replace(c,l&"("&tmpstr&")$",show2(canshu(0)))
case "$nolable"
c=replace(c,l&"("&tmpstr&")$",nolable())
end select
wend
end sub
function author(cc,ll)
author="格式為:"&cc
author=author&""
end function
function show2(ccc)
show2="接收到引數:"&ccc
end function
function nolable()
nolable="這個沒有引數,顯示正常"
end function
%>
方法二:
<%
'標籤組成型別
dim aa
aa=""
response.write tagsarr(aa,4)
'******************************==
'分解完陣列產生輸入函式的字串 2
'例如:key1=2,key1=3
'******************************==
function tagsvalue(byval value)
dimstr_tagsname,str_tagsvalue
'標籤名稱:目前無用,可以在需要的時候呼叫
'str_tagsname =
split(replace(replace(value,"",""),";")(0)
str_tagsvalue =
split(replace(replace(value,"",""),";")(1)
tagsvalue = str_tagsvalue
end function
'******************************==
'裸值輸入定義陣列。1
'說明:分解完標籤獲得輸入值以後,取值長度不能超過tagslen的最大數字
'可以直接使用,直接輸入完整標籤無需分解
'0為第一引數值,1為第二引數值,以此類推
'******************************==
function tagsarr(tagsstr,value)
tagsarr =
split(split(tagsvalue(tagsstr),",")(value),"=")(1)
end function
'******************************==
'函式說明:確定輸入引數長度,返回布林值
'引數:直接輸入完整標籤
'******************************==
function tagslen(strvalue,value)
ifubound(split(tagsvalue(strvalue),","))
<> value then
tagslen = false
else
tagslen = true
end if
end function
%>
方法三 正規表示式
<%
'//函式:帶引數的標籤獲取者
'//引數:diylable:標籤,template:包含標籤的內容,content:變數內容
function replacetestdiy(diylable,template,content)
replacetestdiy=template
dim regex,match,mymatches
set regex=new regexp
regex.pattern = diylable
regex.ignorecase = true
regex.global = true
set mymatches=regex.execute(template)
if mymatches.count<=0 then exit function
for each match in mymatches
diylable=replace(replacetestdiy,"",left(content,match.submatches.item(0)))
next
replacetestdiy=diylable
end function
template="asfsadfasfdsdf"
asp_lable=""
'標題template = replacetestdiy(asp_lable,template,"匯聚心理學界力量
重建心靈家園")
response.write template
%>
帶引數的方法
import inte ce computer nsobject int addnum1 int num1 andnum2 int num2 end implementation computer 返回值型別 方法名 引數型別 引數名 形參標籤 引數型別 引數名 int addnum1 int nu...
帶引數的方法
定義帶參方法 訪問修飾符 返回值型別 方法名 引數列表 訪問修飾符 指該方法允許被訪問的許可權範圍,只能是public protected或private 返回值型別 指方法返回值的型別,如果方法不返回任何值,他應該宣告為void型別。舉個例項 public class studentsbiz pu...
帶引數的方法
根據運輸證帶出可用數量 public double transportationsum double b double convert1 convert.todouble context.diutility.execsql string.format sql,this.transfer lines2...