Its a bit of a tricky regular expression to match a body tag which may or may not have attributes, and also which may be spread over multiple lines. Try this one:
Code:
' the text between the <BODY></BODY> tags will be stored in variable sBodyText
Set re = New RegExp
re.Pattern = "<body(?:.|\n)*?>((?:.|\n)*)</body>"
re.IgnoreCase = True
re.Global = False
re.Multiline = True
Set oMatches = re.Execute(strP)
If Not oMatches Is Nothing Then
If oMatches.Count > 0 Then
If Not oMatches(0).SubMatches Is Nothing Then
sBodyText = oMatches(0).SubMatches(0)
End If
End If
End If
I'll try and explain the regexp:
<body - matches the opening body tag
(?:.|\n)*? - is for attributes, it matches any char, including new-line, zero or more times (the opening ?: prevents the characters here from being stored in the submatches)
((?:.|\n)*) - same again, except we want to capture the whole text between the tags in the submatches collection
</body> - matches the ending body tag
hth
Phil