php专区

 首页 > php专区 > 正则表达式 > asp match正则函数使用Matchs实例_正则表达式

asp match正则函数使用Matchs实例_正则表达式

分享到:
【字体:
导读:
          asp matchs函数提供了对正则表达式匹配的只读属性的访问。一直都用这个函数,没想到本站竟然没有这类文章,汗一个,最近我会多加一些这样的文章...



  说明   
  Match   对象只能通过   RegExp   对象的   Execute   方法来创建,该方法实际上返回了   Match   对象的集合。所有的   Match   对象属性都是只读的。   
  在执行正则表达式时,可能产生零个或多个   Match   对象。每个   Match   对象提供了被正则表达式搜索找到的字符串的访问、字符串的长度,以及找到匹配的索引位置等。   

  下面的代码说明了   Match   对象的用法:     

  Function   RegExpTest(patrn,   strng)   
      Dim   regEx,   Match,   Matches '   建立变量。   
      Set   regEx   =   New   RegExp '   建立正则表达式。   
      regEx.Pattern   =   patrn '   设置模式。   
      regEx.IgnoreCase   =   True '   设置是否区分大小写。   
      regEx.Global   =   True '   设置全局替换。   
      Set   Matches   =   regEx.Execute(strng) '   执行搜索。   
      For   Each   Match   in   Matches '   遍历   Matches   集合。   
          RetStr   =   RetStr   &   "Match   "   &   I   &   "   found   at   position   "   
          RetStr   =   RetStr   &   Match.FirstIndex   &   ".   Match   Value   is   "'   
          RetStr   =   RetStr   &   Match.Value   &   "'."   &   vbCRLF   
      Next   
      RegExpTest   =   RetStr   
  End   Function   

  MsgBox(RegExpTest("is.",   "IS1   is2   IS3   is4"))  
分享到:
asp 图片正则 替换,替换前检查图片是不...
直接用正则替换,但没有判断功能 Function FormatImg(content) dim re Set re=new RegExp re.IgnoreCase =true re.Global=True re.Pattern="(script)" Content=re.Replace(Content,"script") re.Pattern="]*src(=| )(.[^>]*)>" Content=re.replace(Content,"") set re = nothing FormatImg = content End Funct...
ASP正则函数替换分页后的参数_正则表达式
Function DRexPage(Str)     Dim RegEx     If IsNull(Str) Or Str="" Then Exit Function    Set RegEx=New RegExp         RegEx.IgnoreCase=True        RegEx.pattern="(\&)?page=(\d)+"        DRexPage=regEx.replace(Str,"")  '(Str,"$1")         Set ...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……