ASP - Remove line break from text end

Asked

Viewed 486 times

0

With removing several <br /> end of text in ASP 3.0 only?

Texto <br /> texto texto texto <br /><br /><br /><br />

1 answer

0

I made a routine with PHP and from there I tried (more than 15 years I abandoned Asp) the equivalent in ASP.

I just couldn’t test in SP because my server doesn’t support, and I couldn’t find it online to test the code in SP.

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
  1. With Split transform texto in a string array through the delimiter <br />.
  2. Bow-tie FOR, starting at 0 (every Asp array starts at zero position), traverse the array to its last position, which is obtained through the function Ubound
  3. Compare if the last characters of the string are equal to <br /> with the function Right
  4. If yes return the string through the function mid the part of the string that matters.
  • Yes, it will work, I will do a function and apply it to the maches string of that regex, which I am in the fight. rs Mixed darn, but now it will. You have regex in Asp, regex in javascript, and regex for that function to remove brs. Let’s see what I can do. Thanks

  • Rode, almost went. If the brs are in the same line br br br br the strip function, only the damn ckeditor in the question, generates the br one below the other.

  • @Rod, have you tried Replace(texto, Chr(13), "")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.