Regexp元描述

Regexp元描述,regex,vbscript,asp-classic,regex-negation,regexp-like,Regex,Vbscript,Asp Classic,Regex Negation,Regexp Like,当我在(]*description[^>]([^)运行时使用此正则表达式 Match 1 Full match 265-314 `<meta name="description" content="Stackoverflow">` Group 1. 265-314 `<meta name="description" content="Stackoverflow">` Group 2. 289-313 ` content="Stackoverflow" 匹配

当我在
(]*description[^>]([^)
运行时使用此正则表达式

Match 1
Full match  265-314 `<meta name="description" content="Stackoverflow">`
Group 1.    265-314 `<meta name="description" content="Stackoverflow">`
Group 2.    289-313 ` content="Stackoverflow"
匹配1
全场265-314``
第1组265-314``
组2.289-313`content=“Stackoverflow”
但是当我在我的页面上使用它时,它不会运行

Function GetFirstMatch(PatternToMatch, StringToSearch)
    Set regEx = New RegExp
    regEx.Pattern = PatternToMatch
    regEx.IgnoreCase = True
    regEx.Global = True
    regEx.MultiLine = True
    Set CurrentMatches = regEx.Execute(StringToSearch)

    GetFirstMatch = ""
    If CurrentMatches.Count >= 1 Then
        Set CurrentMatch = CurrentMatches(0)
        If CurrentMatch.SubMatches.Count >= 1 Then
            GetFirstMatch = CurrentMatch.SubMatches(0)
        End If
    End If
    Set regEx = Nothing
End Function

GetFirstMatch("(<meta[^>]*description[^>]([^<]+)>)",sdatai)
函数GetFirstMatch(PatternToMatch,StringToSearch) Set regEx=New RegExp regEx.Pattern=PatternToMatch regEx.IgnoreCase=True regEx.Global=True regEx.MultiLine=True Set CurrentMatches=regEx.Execute(StringToSearch) GetFirstMatch=“” 如果CurrentMatches.Count>=1,则 设置CurrentMatch=CurrentMatches(0) 如果CurrentMatch.SubMatches.Count>=1,则 GetFirstMatch=CurrentMatch.SubMatch(0) 如果结束 如果结束 Set regEx=Nothing 端函数 GetFirstMatch((]*description[^>]([^)”,sdatai)
谢谢

这是因为内容中有“description”一词。这会导致正则表达式(
]*description
)的第一部分跳过所有内容,直到最后一次出现“description”。下面是正则表达式,可以解决此问题:

(<meta[\s]+name="description"[^>]([^>]+)>)
([^>]+)>)

sdatai?sdatai=pagehtmldeep请给出一个
sdatai
我的第一个HTML文档的示例

Hello world!