Remove SPAN Tag

The code below is being read from a database. I want to  remove the span tags before it is displayed on the screen, i however want to keep all other tags such as <p>

<SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-GB; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"><p>the road<p/></SPAN>

Im using the following code:

txt = your span content
txt = Right(txt,Len(txt) - Instr(txt,">")) ' positon of first occurance of ">" 
txt = Left(txt,Instr(txt,("</SPAN"))-1)  
Response.Write(txt)

But keep gettin the error: Invalid procedure call or argument 'Left'

can somebody please tell me a way to fix this problem

Thanks Kevin
KeKiteleyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SlimshaneeyCommented:
This might work, not tested, have a try though.

Function clearTags(HTML)
Dim re
Set re = New RegExp
re.Pattern = "(<[?]SPAN[^>]*>)"
re.Global = True
clearTags = re.Replace(HTML, "")
End Function
0
SlimshaneeyCommented:
Also, you could try this, I modified it from another answer....

Function ReplaceFont(ByVal strFormatArea)
    'create variables
    Dim objRegEx
    dim strMatchPattern
     'create instance of RegExp object
    Set objRegEx = New RegExp

     '** FIND ALL MATCHES **
    objRegEx.Global = True
    ' ** SET CASE SENSITIVE **
    objRegEx.IgnoreCase = True

    ' ** GET THE SPANTAG **
     '** looks for a string starting with <SPAN, followed by anything except a closing bracket, followed by a closing bracket **
    strMatchPattern = "<span[^>]+>"
    ' ** SET PATTERN **
    objRegEx.Pattern = strMatchPattern    
     ' ** REMOVE SPAN START TAG **
    strFormatArea = objRegEx.Replace(strFormatArea, "")

     ' ** GET THE SPAN END TAG **
    strMatchPattern = "</span>"
    ' ** SET PATTERN **
    objRegEx.Pattern = strMatchPattern
    ' ** REMOVE THE SPAN END TAG **
    strFormatArea = objRegEx.Replace(strFormatArea, "")
     

    ' Return the result
    ReplaceFont = strFormatArea
    Set objRegEx=nothing
End Function
0
HilaireCommented:
Please try this shorter version

Function RemoveSPanTags(str)
dim obj
set obj = createobject("vbscript.regexp")
with obj
   .global = true
   .pattern = "\<SPAN[^>]*>(.*)</SPAN>"
   str= .replace(str, "$1")
end with
set obj = nothing
end Function
0
HilaireCommented:
Oops typo

Function RemoveSPanTags(str)
dim obj
set obj = createobject("vbscript.regexp")
with obj
   .global = true
   .pattern = "\<SPAN[^>]*>(.*)</SPAN>"
   RemoveSPanTags= .replace(str, "$1")
end with
set obj = nothing
end Function

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.