将HTML文章内容分成两段

<script language="vbscript">
'strng="<a hreF='hhh' taRget='_bland'>dfdfdfdfdDDDDDddtttttttt</A><b>ffffff</b>"
strng="<p>一、         服务需求描述: </p><p><br />  我司在与各地移动合作过程中,会出现我司需要委托当地贵宾诊室代为扣除用户积分操作,这样用户即可直接到相应科室进行就诊服务。 </p><p><br />  二、         功能描述: </p><p><br />  1、 在各个医院全球通贵宾诊室登陆界面中增加【贵宾诊室积分操作】栏目,作为一级栏目存在。 </p><p><br />  2、 贵宾诊室积分界面登陆后,二级目录【积分扣除操作】需要其电话预约的数据进行读出,并增加电话号码、积分扣除数填写。已经填写过的数据,只能由其进行修改。 </p><p><br />"

Function getWhereContent(strng,nums,byref Content1,byref Content2)
   '/定义
   Dim tempStr, regEx, Match, Matches, regEx1, strIndex1, strIndex2, strIndex3
   Set regEx = New RegExp 
   regEx.Pattern = "<(/S*?)[^>]*>"  
   regEx.IgnoreCase = false 
   regEx.Global = True  
   Set Matches = regEx.Execute(strng)   
   Set regEx1 = New RegExp  
   regEx1.Pattern = "<(/S*?)[^>]*>"  
   regEx1.IgnoreCase = false  
   regEx1.Global = True  
   strIndex1 = 0
   strIndex2 = 0
   strIndex3 = 0
  
   '/取得字符区间
   For Each Match in Matches   ' 遍历匹配集合。
   if Match.FirstIndex>0 then
  tempStr = left(strng,Match.FirstIndex)
   else
  tempStr = ""
   end if
   tempStr = regEx1.Replace(tempStr,"")
   if len(tempStr)>nums then
  strIndex2 = Match.FirstIndex
  exit for
   else
  strIndex1 = Match.FirstIndex+len(Match.value)
   end if
   Next
   '/取得字符索引  
   if strIndex1=0 and strIndex2=0 then    '无html标记情况
   if strng>nums then
  strIndex3 = strIndex1
   else
  strIndex3 = len(strng)-1
   end if   
    elseif strIndex2>0 then
     for i = strIndex1 to strIndex2
   tempStr = left(strng,i)
   tempStr = regEx1.Replace(tempStr,"")
   if len(tempStr)>=nums then
    strIndex3 = i-1
    exit for
   end if
     next
 elseif strIndex1>0 then
     for i = strIndex1 to len(strng)
   tempStr = left(strng,i)
   tempStr = regEx1.Replace(tempStr,"")
   if len(tempStr)>=nums then
    strIndex3 = i-1
    exit for
   end if
     next
  if strIndex3=0 then
   strIndex3 = len(strng)-1
  end if
 end if
         
 Content1= left(strng,strIndex3+1)
 Content2= right(strng,len(strng)-strIndex3-1) 
End Function


getWhereContent strng,100,t1,t2
msgbox(t1)
msgbox(t2)
</script> 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值