截取中间字符串问题!!!!

good3g 2008-07-08 04:22:07
有字符串A="http://www.***.comftp://www.***.comhttp://www.***.comhttp://www.***.com"
我要得到b="ftp://www***.com"


***是变量,ftp://www***.com位置不定,http://www.***.com有很多个,但ftp://www***.com只有一个
...全文
179 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
lzp4881 2008-07-08
  • 打赏
  • 举报
回复
对了,还应该把//去掉
str=A
str1=split(str,"ftp://")
str2=split(str1(1),"http")
b=str2(0)
good3g 2008-07-08
  • 打赏
  • 举报
回复
还是简单的好用,19楼的还行,再多测试下!!!!!
good3g 2008-07-08
  • 打赏
  • 举报
回复
碰上怪事了,直接输入
str = "http://www.***.comftp://www.***.comhttp://www.***.comhttp://www.***.com"
测试可以
但是
str = ""&mycasu&""
就不行了,
mycasu是没问题的呀!

奶奶的.
急死了!
lzp4881 2008-07-08
  • 打赏
  • 举报
回复
str=A
str1=split(str,"ftp")
str2=split(str1(1),"http")
b=str2(0)
刚才发错了
lzp4881 2008-07-08
  • 打赏
  • 举报
回复
str=A
str1=split(a,"ftp")
str2=split(str1(1),"http")
b=str2(0)
good3g 2008-07-08
  • 打赏
  • 举报
回复
12楼的不行啊!!!.net.cn地址不能用
wcwtitxu 2008-07-08
  • 打赏
  • 举报
回复

Dim regex, matches, found, str
str = "http://www.***.comftp://www.***.comhttp://www.***.comhttp://www.***.com"
Set re = New RegExp
re.Pattern = "ftp\://.+?(?=http\://|$)"
Set matches = re.Execute(str)
If matches.Count Then
found = matches.Item(0).Value
Response.Write found
Else
' 没有匹配
End If
Set matches = Nothing
Set re = Nothing
  • 打赏
  • 举报
回复
是没有,但是按逻辑上是不行的,不完全符合
good3g 2008-07-08
  • 打赏
  • 举报
回复
嗯,不错不错,不过我那个方法也可以设成10000呀,我想是没有比100长的网址吧?
good3g 2008-07-08
  • 打赏
  • 举报
回复
我试一下
  • 打赏
  • 举报
回复
<%str="http://www.***.comftp://www.***1.comhttp://www.***.comhttp://www.***.com"
Set re = new RegExp
re.IgnoreCase = True
re.Global = True
re.Pattern ="ftp:\/\/(.+)\.comhttp"
Set Matches = re.Execute(str)
str=Matches(0)
Set re = Nothing
Set re = new RegExp
re.IgnoreCase = True
re.Global = True
re.Pattern ="http(.*?)http"
response.Write re.Replace(str,"")
Set re = Nothing
%>
  • 打赏
  • 举报
回复
str="http://www.***.comftp://www.***1.comhttp://www.***.comhttp://www.***.com"
Set re = new RegExp
re.IgnoreCase = True
re.Global = True
re.Pattern ="ftp:\/\/(.+)\.comhttp"
Set Matches = re.Execute(str)
str=Matches(0)
Set re = Nothing
Set re = new RegExp
re.IgnoreCase = True
re.Global = True
re.Pattern ="http(.*?)http"
response.Write re.Replace(str,"")
Set re = Nothing
  • 打赏
  • 举报
回复
竟然是用这个方法,真晕!!

假如你的str2(0)有200个字符呢?
拿你那个又不能用了
还是正则比较实在
good3g 2008-07-08
  • 打赏
  • 举报
回复
自已已解决
str=A
str=split(str11,ftp)
str2=left(str(1),10000)
str2=split(str2,"HTTP")
B=left(str2(0),100)
ly8199 2008-07-08
  • 打赏
  • 举报
回复
找不到http的话就是全部抓取了。
ly8199 2008-07-08
  • 打赏
  • 举报
回复
找到 ftp:// 抓取 f位置开始之后的字符
再找到 http:// 抓取h之前的字符
good3g 2008-07-08
  • 打赏
  • 举报
回复
我不是要取http://www.***.com
我是要取ftp://之间那个!!!
HimeTale 2008-07-08
  • 打赏
  • 举报
回复
用正则表达式啊
比如
/(?<=http://www\.).*?(\.com)/
取的是http://www.和.com中间的串。
js下怎么用正则你看看吧
good3g 2008-07-08
  • 打赏
  • 举报
回复
不行啊!!!!会造成错误!!!!
zhanshanhu 2008-07-08
  • 打赏
  • 举报
回复
getsplit=split(A,".com")
for i=0 to udoub(split(A,".com"))
if left(getsplit(i),3)="fpt" then
b=getsplit(i)&".com"
end if
next

不知道这样行不
加载更多回复(2)

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧