娱乐圈过气明星现状:高难字符串问题,ASP的

来源:百度文库 编辑:高考问答 时间:2024/05/04 17:48:52
[center]文字文字文字文字文字文字文字文字文字[img]123/123.jpg[/img]文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字[/center]
问:怎么取出[img]123/123.jpg[/img]?
另:[img]123/123.jpg[/img]可能出现在文章中,也可能在开头,位置不一定。

<%str="[center]..."
str1="[img]"
str2="[/img]"
strstar=instr(str,str1)
strend=instr(str,str2)
str3=mid(str,strstar,(strend-strstar+len(str2)))

我不记得asp中的函数怎么使,只提供一个思路。
假设“[center]文字文字文字文字文字文字文字文字文字[img]123/123.jpg[/img]文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字[/center]”在字符串str中
a=str中[img]的位置
b=str中[/img]的位置
再用mid函数从a位置取b+6-a个字符就可以了。