Now that Stephanie's problem is solved, going back a little:
shg posted:
That doesn't look for matching tags, does it: <B>Hello</B>. You'd need a back reference in the second expression, wouldn't you?
I think we could include the backreference without making the pattern much more complex.
Using part of Reafidy's code #8 (hope he doesn't mind), I believe this code would delete HTML tag pairs:
Function sNoHtml(ByVal sHtml As String) As String
' Using Late Binding But Use Can Use Early If You Set The Reference
Dim RegEx As Object
Set RegEx = CreateObject("vbscript.regexp")
' set the RegExp parameters
With RegEx
'look for global matches
.Global = True
'ignore case
.IgnoreCase = True
.Pattern = "<(\w*)[^>]*>(.*?)</\1>"
' strip the HTML tags
While .test(sHtml)
sHtml = .Replace(sHtml, "$2")
Wend
sNoHtml = sHtml
End With
' set any additional criteria here
sNoHtml = Replace(sNoHtml, " ", "")
Set RegEx = Nothing
End Function
Remark: Not all HTML tags come in pairs. That's why this code wouldn't be enough. If it's XHTM we could add strings that start with "<" and end with "/>". If it's pure HTML it would be wilder as it allows for a loose syntax.
Best regards
lecxe
Bookmarks