webForumDet fria alternativet

RegEx

2 svar · 143 visningar · startad av saw

sawMedlem sedan mars 20011 880 inlägg
#1

Jag vill kontrollera om en include-tag finns.

Dim regxp As Object, oMatch As Object, MatchC As Object
    Set regxp = CreateObject("VBScript.RegExp")
    regxp.IgnoreCase = True
    
    regxp.Pattern = "<!--#include file=""common-lib.asp""-->"
    Set MatchC = regxp.Execute(txtHtml.text)
    
    Set oMatch = MatchC(0)
    txtHtml.SelStart = oMatch.FirstIndex
    txtHtml.SelLength = oMatch.Length

    txtHtml.SelText = vbCrLf & "<!--#include file=""common-lib.asp""-->" & vbCrLf

Jag får ett error på Set oMatch = MatchC(0).
Hur fixar jag till det?

Nexus86Medlem sedan okt. 20023 030 inlägg
#2
  Dim regxp As Object, oMatch As Object, MatchC As Object
    Set regxp = CreateObject("VBScript.RegExp")
    regxp.IgnoreCase = True
    
    regxp.Pattern = "<!--#include file=""common-lib.asp""-->"
    If regxp.Test(txtHtml.Text) Then
        ' Det finns en include med common-lib.asp som fil-attribut
    Else
        ' Det finns inte
    End If
sawMedlem sedan mars 20011 880 inlägg
#3

Tack helt perfekt

130 ms totalt · 3 externa anrop · v20260731065814-full.30151723
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
128 ms — hämta tråd, inlägg och bilagor (db)