vbscript/asp函数:extract_by_str,指定起止字符串在字符串中截取子串

vbscript/asp函数:extract_by_str,指定起止字符串在字符串中截取子串

直接上代码:

<%
function extract_by_str(from,s_start,s_end)
	dim pos_start,pos_end,rtn
 	rtn="" 	
 	pos_start=instr(from,s_start)
 	if pos_start>0 then
		pos_start=pos_start+len(s_start)
		pos_end=instr(pos_start,from,s_end)
		if pos_end > pos_start then
			rtn=mid(from,pos_start,pos_end-pos_start)
		end if
	end if
	extract_by_str=rtn
end function

str="[abcdefghijklmn天地玄黄宇宙洪荒]abcxyzopqlmn"
response.write str
response.write "c-i:"&extract_by_str(str,"c","i")
response.write "天-洪:"&extract_by_str(str,"天","洪")
response.write "天-洪:"&extract_by_str(str,"洪","天")
response.write "天-e:"&extract_by_str(str,"天","e")
response.write "天-n:"&extract_by_str(str,"天","n")
%>
发表评论?

0 条评论。

发表评论