我的html(TextBox1.Text):
<b>
Hello world!
</b>
我的VB.Net正则表达式代码:
Dim findtext2 As String = "(?<=<b>)(.*?)(?=</b>)"
Dim myregex2 As String = TextBox1.Text
Dim doregex2 As MatchCollection = Regex.Matches(myregex2, findtext2)
Dim matches2 As String = ""
For Each match2 As Match In doregex2
matches2 = matches2 + match2.ToString + Environment.NewLine
Next
MsgBox(matches2)
它不起作用!然而经过几个小时的研究后我发现这个正则表达式只在单行上工作,这意味着它可以在 <b>Hello world!</b>
上工作,但如果html标签之间有换行符则无效