String manipulation

  • Thread starter Thread starter Eric S
  • Start date Start date
E

Eric S

Hi All,

Any idea how to load the below as one string? I need to remove the spaces
and currage return between lines.

Thanks,

Eric

<td colspan="2">
To verify an individual's Date of Birth, requires several databases to
be queried and checked to valid an legitimate date of birth.
<br/>
<br/>
Upon success the search will provide:
<br/>
<ol class="BlueCheckMark">
<li>Name</li>
<li>Address</li>
<li>Phone</li>
<li>Relatives</li>
</ol>
Search results will display:
<ol class="Bullet">
<li> Verified DOB - Successful Match</li>
<li> Un-Verified DOB - Not a Match</li>
</ol>
</td>
 
Do you want to do this server side? If so, you could use String.Replace or a
regular expression. Using a regular expression might be faster. There are
tons of examples on the web.

David

======================================
David McCarter [Microsoft MVP]
www.dotNetTips.com
David McCarter''s .NET Coding Standards available at:
http://codingstandards.notlong.com
 
Hi David,

Thanks for your reply.
I need basically to figure out each line in that string and then comined
them all together as one line, and do that on the server level.

Thanks,

Eric

dotNetDave said:
Do you want to do this server side? If so, you could use String.Replace or
a
regular expression. Using a regular expression might be faster. There are
tons of examples on the web.

David

======================================
David McCarter [Microsoft MVP]
www.dotNetTips.com
David McCarter''s .NET Coding Standards available at:
http://codingstandards.notlong.com


Eric S said:
Hi All,

Any idea how to load the below as one string? I need to remove the spaces
and currage return between lines.

Thanks,

Eric

<td colspan="2">
To verify an individual's Date of Birth, requires several databases
to
be queried and checked to valid an legitimate date of birth.
<br/>
<br/>
Upon success the search will provide:
<br/>
<ol class="BlueCheckMark">
<li>Name</li>
<li>Address</li>
<li>Phone</li>
<li>Relatives</li>
</ol>
Search results will display:
<ol class="Bullet">
<li> Verified DOB - Successful Match</li>
<li> Un-Verified DOB - Not a Match</li>
</ol>
</td>
 
Hi Eric,

The easiest way (though a compiled regular expression might be faster) is
below:

string x = @"abc
defg";

x = x.Replace("\n", "");

--
Coskun Sunali
Microsoft MVP - ASP.NET
http://sunali.com
http://propeople.dk

Eric S said:
Hi David,

Thanks for your reply.
I need basically to figure out each line in that string and then comined
them all together as one line, and do that on the server level.

Thanks,

Eric

dotNetDave said:
Do you want to do this server side? If so, you could use String.Replace
or a
regular expression. Using a regular expression might be faster. There are
tons of examples on the web.

David

======================================
David McCarter [Microsoft MVP]
www.dotNetTips.com
David McCarter''s .NET Coding Standards available at:
http://codingstandards.notlong.com


Eric S said:
Hi All,

Any idea how to load the below as one string? I need to remove the
spaces
and currage return between lines.

Thanks,

Eric

<td colspan="2">
To verify an individual's Date of Birth, requires several databases
to
be queried and checked to valid an legitimate date of birth.
<br/>
<br/>
Upon success the search will provide:
<br/>
<ol class="BlueCheckMark">
<li>Name</li>
<li>Address</li>
<li>Phone</li>
<li>Relatives</li>
</ol>
Search results will display:
<ol class="Bullet">
<li> Verified DOB - Successful Match</li>
<li> Un-Verified DOB - Not a Match</li>
</ol>
</td>
 
Thanks.

I used the x.Split() first and then just concatenated all rows.



Coskun Sunali said:
Hi Eric,

The easiest way (though a compiled regular expression might be faster) is
below:

string x = @"abc
defg";

x = x.Replace("\n", "");

--
Coskun Sunali
Microsoft MVP - ASP.NET
http://sunali.com
http://propeople.dk

Eric S said:
Hi David,

Thanks for your reply.
I need basically to figure out each line in that string and then comined
them all together as one line, and do that on the server level.

Thanks,

Eric

dotNetDave said:
Do you want to do this server side? If so, you could use String.Replace
or a
regular expression. Using a regular expression might be faster. There
are
tons of examples on the web.

David

======================================
David McCarter [Microsoft MVP]
www.dotNetTips.com
David McCarter''s .NET Coding Standards available at:
http://codingstandards.notlong.com


:

Hi All,

Any idea how to load the below as one string? I need to remove the
spaces
and currage return between lines.

Thanks,

Eric

<td colspan="2">
To verify an individual's Date of Birth, requires several databases
to
be queried and checked to valid an legitimate date of birth.
<br/>
<br/>
Upon success the search will provide:
<br/>
<ol class="BlueCheckMark">
<li>Name</li>
<li>Address</li>
<li>Phone</li>
<li>Relatives</li>
</ol>
Search results will display:
<ol class="Bullet">
<li> Verified DOB - Successful Match</li>
<li> Un-Verified DOB - Not a Match</li>
</ol>
</td>
 
Hi Eric,

Glad to hear that you found a solution. However, I would like to remind you
that "string" is a Reference type and concatenation operations might cause
high memory usage. Please consider using StringBuilder in such a case or
simply use Regular Expressions or string.Replace.


--
Coskun Sunali
Microsoft MVP - ASP.NET
http://sunali.com
http://propeople.dk

Eric S said:
Thanks.

I used the x.Split() first and then just concatenated all rows.



Coskun Sunali said:
Hi Eric,

The easiest way (though a compiled regular expression might be faster) is
below:

string x = @"abc
defg";

x = x.Replace("\n", "");

--
Coskun Sunali
Microsoft MVP - ASP.NET
http://sunali.com
http://propeople.dk

Eric S said:
Hi David,

Thanks for your reply.
I need basically to figure out each line in that string and then comined
them all together as one line, and do that on the server level.

Thanks,

Eric

Do you want to do this server side? If so, you could use String.Replace
or a
regular expression. Using a regular expression might be faster. There
are
tons of examples on the web.

David

======================================
David McCarter [Microsoft MVP]
www.dotNetTips.com
David McCarter''s .NET Coding Standards available at:
http://codingstandards.notlong.com


:

Hi All,

Any idea how to load the below as one string? I need to remove the
spaces
and currage return between lines.

Thanks,

Eric

<td colspan="2">
To verify an individual's Date of Birth, requires several databases
to
be queried and checked to valid an legitimate date of birth.
<br/>
<br/>
Upon success the search will provide:
<br/>
<ol class="BlueCheckMark">
<li>Name</li>
<li>Address</li>
<li>Phone</li>
<li>Relatives</li>
</ol>
Search results will display:
<ol class="Bullet">
<li> Verified DOB - Successful Match</li>
<li> Un-Verified DOB - Not a Match</li>
</ol>
</td>
 
Hi Coskun ,

Here is the below that I used:

Public Shared Function HTMLConcatenateString(ByVal cHTMLString As String) As
String
Dim concatenatedText As String = String.Empty
Dim currentHTMLData() As String = cHTMLString.Split(vbCr)
If currentHTMLData.Length > 0 Then
For Each htmlRecordText As String In currentHTMLData
concatenatedText = concatenatedText + htmlRecordText.Trim
Next
End If

HTMLConcatenateString = concatenatedText
End Function

The problem is that the x.Replace() did not fix it since probably there were
some other empty characters after each line.
Here is an example of that string:

<td>
Complete search on any individual.
<br/>
This report will provide basic information on all matches.
<ol class="BlueCheckMark">
<li>Full Name</li>
<li>Address</li>
<li>Phone Number</li>
<li>Date of Birth</li>
<li>Possible Relatives</li>
</ol>
</td>

Thanks,

Eric


Coskun Sunali said:
Hi Eric,

Glad to hear that you found a solution. However, I would like to remind
you that "string" is a Reference type and concatenation operations might
cause high memory usage. Please consider using StringBuilder in such a
case or simply use Regular Expressions or string.Replace.


--
Coskun Sunali
Microsoft MVP - ASP.NET
http://sunali.com
http://propeople.dk

Eric S said:
Thanks.

I used the x.Split() first and then just concatenated all rows.



Coskun Sunali said:
Hi Eric,

The easiest way (though a compiled regular expression might be faster)
is below:

string x = @"abc
defg";

x = x.Replace("\n", "");

--
Coskun Sunali
Microsoft MVP - ASP.NET
http://sunali.com
http://propeople.dk

Hi David,

Thanks for your reply.
I need basically to figure out each line in that string and then
comined them all together as one line, and do that on the server level.

Thanks,

Eric

Do you want to do this server side? If so, you could use
String.Replace or a
regular expression. Using a regular expression might be faster. There
are
tons of examples on the web.

David

======================================
David McCarter [Microsoft MVP]
www.dotNetTips.com
David McCarter''s .NET Coding Standards available at:
http://codingstandards.notlong.com


:

Hi All,

Any idea how to load the below as one string? I need to remove the
spaces
and currage return between lines.

Thanks,

Eric

<td colspan="2">
To verify an individual's Date of Birth, requires several
databases to
be queried and checked to valid an legitimate date of birth.
<br/>
<br/>
Upon success the search will provide:
<br/>
<ol class="BlueCheckMark">
<li>Name</li>
<li>Address</li>
<li>Phone</li>
<li>Relatives</li>
</ol>
Search results will display:
<ol class="Bullet">
<li> Verified DOB - Successful Match</li>
<li> Un-Verified DOB - Not a Match</li>
</ol>
</td>
 
Back
Top