我希望在WhiteSpaces时从url剪切文本

时间:2013-05-10 00:42:01

标签: asp-classic

例如,地址为:start http://127.0.0.1.co.th/af start

   I want to cut text from url when WhiteSpaces http://127.0.0.1.co.th/af
  <% str = "start http://127.0.0.1.co.th/af start"
   # cut start from url
  if instr(str,"http://")<> 0 then
  str = right(str,len(str) - instr(str,"http://") +1)
  end If
  if instr(str," ") <> 0 then
  str = left(str,instr(str," ") +3)
  end If
  %>
  <%=str%>
   I want to cut text from url when WhiteSpaces http://127.0.0.1.co.th/af start
   (cut start) How do it thk you

1 个答案:

答案 0 :(得分:0)

假设您正在尝试从可能包含空格的字符串中删除URL,那么您的代码非常接近。看起来你的第二个if语句有点截断URL。

这应该有效:

<% 
str = "start http://127.0.0.1.co.th/af start"

if instr(str,"http://")<> 0 then
    str = right(str,len(str) - instr(str,"http://") +1)
end if
if instr(str," ") <> 0 then
    str = left(str,instr(str," "))
end if
%>

<%=str%>