/ Forside / Teknologi / Udvikling / ASP / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
ASP
#NavnPoint
smorch 9259
Harlekin 1866
molokyle 1040
Steffanst.. 758
gandalf 657
smilly 564
gibson 560
cumano 530
MouseKeep.. 480
10  Random 410
Replace(strTemp problem
Fra : Michael Tillgaard


Dato : 12-10-07 14:22

Jeg bøvler lidt med følgende:
<DIV style="MARGIN: 0cm 0cm 0pt"> skal fjernes når recordset
vises.
Jeg bruger dette:
<%
Function replaceSpecialChars(ByVal strText)
Dim strTemp
strTemp = Replace(strText,"'","&#39;")
strTemp = Replace(strTemp,"<DIV>","")
strTemp = Replace(strTemp,"</DIV>","")
replaceSpecialChars = strTemp
End Function
%>
Hvordan skal strTemp se ud for at <DIV style="MARGIN: 0cm 0cm
0pt"> fjernes?

--
Vil du lære at kode HTML, XHTML, CSS, SSI, ASP eller ASP.NET?
- Pædagogiske tutorials på dansk
- Kom godt i gang med koderne
KLIK HER! => http://www.html.dk/tutorials

 
 
Philip Nunnegaard (12-10-2007)
Kommentar
Fra : Philip Nunnegaard


Dato : 12-10-07 14:32

> Hvordan skal strTemp se ud for at <DIV style="MARGIN: 0cm 0cm
> 0pt"> fjernes?

Vel noget i denne dur:
strTemp = Replace(strTemp,"<DIV style=""MARGIN: 0cm 0cm 0pt"">","")
Altså dobbelt anførselstegn for de anførselstegn, der er i strengen. Jeg går
ud fra, at det er det, der volder dig problemer.


Thrane (12-10-2007)
Kommentar
Fra : Thrane


Dato : 12-10-07 17:21


"Michael Tillgaard" <post@bogkassen.dk> wrote in message
news:470f74db$0$90267$14726298@news.sunsite.dk...
> Jeg bøvler lidt med følgende:
> <DIV style="MARGIN: 0cm 0cm 0pt"> skal fjernes når recordset
> vises.
> Jeg bruger dette:
> <%
> Function replaceSpecialChars(ByVal strText)
> Dim strTemp
> strTemp = Replace(strText,"'","&#39;")
> strTemp = Replace(strTemp,"<DIV>","")
> strTemp = Replace(strTemp,"</DIV>","")
> replaceSpecialChars = strTemp
> End Function
> %>
> Hvordan skal strTemp se ud for at <DIV style="MARGIN: 0cm 0cm
> 0pt"> fjernes?

Til at strippe HTML, benytter jeg denne funktion, måske du kan bruge den:

Function META_StripHTML(strHTML)
'Strips the HTML tags from strHTML

Dim objRegExp, strOutput
Set objRegExp = New Regexp

objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<(.|\n)+?>"

'Replace all HTML tag matches with the empty string
strOutput = objRegExp.Replace(strHTML, "")

'Replace all < and > with &lt; and &gt;
strOutput = Replace(strOutput, "&nbsp;", "")
strOutput = Replace(strOutput, "<", "&lt;")
strOutput = Replace(strOutput, ">", "&gt;")

META_StripHTML = strOutput 'Return the value of strOutput

Set objRegExp = Nothing
End Function

--
Thrane


Michael Tillgaard (13-10-2007)
Kommentar
Fra : Michael Tillgaard


Dato : 13-10-07 23:42

Thrane wrote in dk.edb.internet.webdesign.serverside.asp:
KLIP
> Til at strippe HTML, benytter jeg denne funktion, måske du kan bruge den:
>
> Function META_StripHTML(strHTML)
> 'Strips the HTML tags from strHTML
>
> Dim objRegExp, strOutput
> Set objRegExp = New Regexp
>
> objRegExp.IgnoreCase = True
> objRegExp.Global = True
> objRegExp.Pattern = "<(.\n)+?>"
>
> 'Replace all HTML tag matches with the empty string
> strOutput = objRegExp.Replace(strHTML, "")
>
> 'Replace all < and > with < and >
> strOutput = Replace(strOutput, " ", "")
> strOutput = Replace(strOutput, "<", "<")
> strOutput = Replace(strOutput, ">", ">")
>
> META_StripHTML = strOutput 'Return the value of strOutput
>
> Set objRegExp = Nothing
> End Function
>
> --
> Thrane
>
Tak for begge svar.

--
Vil du lære at kode HTML, XHTML, CSS, SSI, ASP eller ASP.NET?
- Pædagogiske tutorials på dansk
- Kom godt i gang med koderne
KLIK HER! => http://www.html.dk/tutorials

Søg
Reklame
Statistik
Spørgsmål : 177459
Tips : 31962
Nyheder : 719565
Indlæg : 6408174
Brugere : 218881

Månedens bedste
Årets bedste
Sidste års bedste