【发布时间】:2018-05-02 08:21:01
【问题描述】:
当我在 https://regex101.com (<meta[^>]*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"
但是当我在我的页面上使用它时它不会运行。
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)
谢谢
【问题讨论】:
-
sdatai中有什么内容? -
sdatai=pagehtmlcode
-
请举一个
sdatai的例子。 -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <HTML> <HEAD> <TITLE>My first HTML document</TITLE> <meta name="description" content="This is an example of a meta description. This will often show up in search results."> </HEAD> <BODY> <P>Hello world! </BODY> </HTML>
标签: regex vbscript asp-classic regex-negation regexp-like