webForumDet fria alternativet
Logga in / Bli medlem

RegEx

.NET

2 svar · 143 visningar · startad av saw

Medlem sedan mars 20011 880 inlägg
Trådstart#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?

Medlem 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
Medlem sedan mars 20011 880 inlägg
#3

Tack helt perfekt

431 ms totalt · 4 externa anrop · v20260731065814-full.81e7e81c
127 ms — deklarationer (db)
0 ms — hämta statistik (cache)
299 ms — hämta tråd, inlägg och bilagor (db)
120 ms — ändringar (db)