468,253 Members | 1,293 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,253 developers. It's quick & easy.

.replace of extra line feeds

Hello.

I just converted some data to to sql2000 into a TEXT type field. I
needed to remove all tabs from the data and now want to remove extra
lines too.
As we know, SQL2000's replace function does not work on TEXT types. So
I've written a simple asp.net program (with very high timeouts) that
allows me to replace strings in these very large Text fields. I loop
through the table and am able to replace any strings I want except I
can't seem to figure out how to replace extra blank lines with a
single line feed and carriage return.

Comparing the old data to the new data. I see I have extra hex values
between lines of

old = 0D0A
new = 0D0A0D0A

so I'm looking to replace 0D0A0D0A with 0D0A.

Here's the asp.net (VB) I have tried. None yeild the change:

dim thebody as string
thebody=thebody.replace(chr(13)+chr(10)+chr(13)+ch r(10),chr(13)+chr(10))
thebody=thebody.replace(chr(13)&chr(10)&chr(13)&ch r(10),chr(13)&chr(10))
thebody=thebody.replace(vbCrLf&vbCrLf,vbCrLf)

Again, the same logic does replace any other string including Tab =
chr(9)

Thanks for any help or info!
Nov 17 '05 #1
2 3622
did you try Environment.NewLine?

If you try ret=thebody.IndexOf(vbcrlf) or chr(13) chr(10) do you
get a value greater then -1 in the string?

If in worst case you can try looping throught the string substring or
miding the results together.

Mike
ja***@cyberpine.com wrote in message news:<ef**************************@posting.google. com>...
Hello.

I just converted some data to to sql2000 into a TEXT type field. I
needed to remove all tabs from the data and now want to remove extra
lines too.
As we know, SQL2000's replace function does not work on TEXT types. So
I've written a simple asp.net program (with very high timeouts) that
allows me to replace strings in these very large Text fields. I loop
through the table and am able to replace any strings I want except I
can't seem to figure out how to replace extra blank lines with a
single line feed and carriage return.

Comparing the old data to the new data. I see I have extra hex values
between lines of

old = 0D0A
new = 0D0A0D0A

so I'm looking to replace 0D0A0D0A with 0D0A.

Here's the asp.net (VB) I have tried. None yeild the change:

dim thebody as string
thebody=thebody.replace(chr(13)+chr(10)+chr(13)+ch r(10),chr(13)+chr(10))
thebody=thebody.replace(chr(13)&chr(10)&chr(13)&ch r(10),chr(13)&chr(10))
thebody=thebody.replace(vbCrLf&vbCrLf,vbCrLf)

Again, the same logic does replace any other string including Tab =
chr(9)

Thanks for any help or info!

Nov 17 '05 #2
mi**@high-pow-er.com (Michael Evanchik) wrote in message news:<36**************************@posting.google. com>...
did you try Environment.NewLine?

If you try ret=thebody.IndexOf(vbcrlf) or chr(13) chr(10) do you
get a value greater then -1 in the string


Thanks for response.

I did not, but that actually would have uncovered my problem. After
posting I did a select in sql2000 QA and found that either asp.net or
the html textbox was adding a chr(10)=Line Feed between consecutive
chr(13)s=Carriage Returns Only in the textbox, not found in the DB.
So, I was able to fix my Text type fields by preplacing
chr(13)&chr(13) to "".

I've seen a number of posts listing very long and complicated SQL2000
stored procs to performing what should be a simple text string
replace. ASP.NET seems to be a simple way around the problem!
Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Marty | last post: by
1 post views Thread by Frank Esser | last post: by
3 posts views Thread by John K | last post: by
4 posts views Thread by jgabbai | last post: by
6 posts views Thread by =?Utf-8?B?R2Vvcmdl?= | last post: by
8 posts views Thread by Kurt Peters | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.