With a Function, how can I get rid of formating codes like <di
On Mon, 1 Jun 2009 10:36:01 -0700, AFSSkier
wrote:
Ron,
Your UDF code works great, however there are still additional formatting
codes like (hard return), and &
--
Thanks, Kevin
That's just a matter of adding those codes to the Pattern.
A code like nbsp has to be added as the hexadecimal ascii code for that which
is A0.
\r and \n are the codes for <CR and <LF
and the & stands alone -- but I don't know how to tell the difference between
an ampersand used as part of a text string, and one being used as a formatting
code.
But try this for the pattern line in the UDF.
======================
re.Pattern = "<[^<]+|[&\xA0\r\n]"
======================
Or, all together:
==============================
Option Explicit
Function StripFormat(S As String) As String
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "<[^<]+|[&\xA0\r\n]"
StripFormat = re.Replace(S, "")
End Function
=================================
--ron
|