I would like to insert the following into a string
<p>some text here</p> <p>some text here</p> <p>some text here</p>
I want it to go into a string as follows
<p>some text here</p><p>some text here</p><p>some text here</p>
i.e. without the carriage returns.
How do I achieve this?
replaceAll("\\n", ""); s = s. replaceAll("\\r", ""); But this will remove all newlines. Note the double \ 's: so that the string that is passed to the regular expression parser is \n .
It handles all line terminator characters (LF, CR, etc). The method also removes any leading or trailing spaces or tabs. The trim() method doesn't change the original string, it returns a new string. Strings are immutable in JavaScript.
Use the strip() Function to Remove a Newline Character From the String in Python. The strip() function is used to remove both trailing and leading newlines from the string that it is being operated on. It also removes the whitespaces on both sides of the string.
Since you're using VB.NET, you'll need the following code:
Dim newString As String = origString.Replace(vbCr, "").Replace(vbLf, "")
You could use escape characters (\r
and \n
) in C#, but these won't work in VB.NET. You have to use the equivalent constants (vbCr
and vbLf
) instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With