Kevin,
Also, there are, according to one source, 53 ampersand codes. If you want to
be able to replace all of them, we will need to set up an array, or lookup
table, to do so. Not difficult, just tedious.
--ron
Here's one method that first replaces all of the ampersand codes with their
ASCII equivalents, and then strips out the <...> codes.
It assumes that the ampersand codes do NOT have any included spaces. (If they
do, different coding will be required).
If you copy this, be aware that the lines making up the array should all be on
one single line. Your newsreader (or mine) may insert inadvertent line breaks
that you will need to remove to make it work correctly.
=================================
Option Explicit
Function StripFormat(S As String) As String
Dim AmpCodes, AmpChars
Dim i As Long
Dim sTemp As String
Dim re As Object
AmpCodes = Array(""", "&", "<", ">", " ", "¡",
"¢", "£", "¤", "¥", "¦", "§", "¨",
"©", "ª", "«", "¬", "Â", "®", "¯", "°",
"±", "²", "³", "´", "µ", "¶", "·",
"¸", "¹", "º", "»", "¼", "½", "¾",
"¿", "×", "÷", "Ã", "ð", "Þ", "þ",
"Æ", "æ", "Œ", "œ", "Å", "Ø", "Ç",
"ç", "ß", "Ñ", "ñ")
AmpChars = Array("""", "&", "<", ">", " ", "¡", "¢", "£", "¤", "¥", "¦", "§",
"¨", "©", "ª", "«", "¬", "Â", "®", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·",
"¸", "¹", "º", "»", "¼", "½", "¾", "¿", "×", "÷", "Ã", "ð", "Þ", "þ", "Æ", "æ",
"Œ", "œ", "Å", "Ø", "Ç", "ç", "ß", "Ñ", "ñ")
'Replace HTML Ampersand Codes
sTemp = S
For i = 0 To UBound(AmpCodes)
sTemp = Replace(sTemp, AmpCodes(i), AmpChars(i))
Next i
'Strip out <> codes; CR and LF
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "<[^<>]+>|[\r\n]"
StripFormat = re.Replace(sTemp, "")
End Function
=====================================
--ron