ASP - Remove line break from the end of the text

0

Withdrawing multiple% w / w% of end-of-text in ASP 3.0?

Texto <br /> texto texto texto <br /><br /><br /><br />
    
asked by anonymous 31.05.2018 / 18:51

1 answer

0

I did a routine with PHP and from there I tried (over 15 years I left asp) the equivalent in ASP.

I just can not test in asp because my server does not support, nor did I find online to test the code in asp.

texto="Texto <br /> texto texto texto <br /><br /><br /><br />"
'transforma em array
partes = Split(texto, "<br />")

For i = 0 to Ubound(partes)

  comprimento = Len(texto)

    If (Right(texto,6)=="<br />" Then

      texto=mid(texto,1,(comprimento-6))

    Else

      Exit For

    End If

Next

response.write texto
  • With Split transform texto into an array of strings through the <br /> delimiter.
  • With the loop FOR , starting at 0 (all arrays in asp start at position zero), scroll the array to its last position, which is obtained through the function Ubound
  • Compare if the last characters of the string is equal to <br /> with the function Right
  • If so, return the string with the mid function to the part of the string that matters.
  • 31.05.2018 / 20:41