Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
883 views
in Technique[技术] by (71.8m points)

.net - Remove carriage return from string

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 ( and ) in C#, but these won't work in VB.NET. You have to use the equivalent constants (vbCr and vbLf) instead.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...