Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need a reorg for .NET Framework 4
Message
From
24/07/2010 20:20:22
 
 
To
24/07/2010 18:57:34
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01473537
Message ID:
01473731
Views:
37
Wait a minute, I've come up with another iteration of this and this time it will not remove your empty lines. Dunno why I didn't think of it earlier:
string CRLF = "\r\n";
string CR = "\r";
string LF = "\n";
string TestString = string.Format("Test this string. {0}It contains {1}{2}a blank line.", CRLF, CRLF, CRLF);
// first replace the LFs
TestString = TestString.Replace(LF, "");
// then split on the CRs
string[] lines = TestString.Split(CR.ToCharArray());

for (int i = 0; i < lines.Length; i++)
{
	Debug.WriteLine(lines[i]);
}
The only thing I haven't tested is performance, but since you have the large strings, I'll leave that up to you.

~~Bonnie




>>Well, that is weird behavior (the thing with the LF). If your empty lines contain more than just a CRLF (like, say they contain a space or a tab), then my example will retain that "empty" line. But, anyway, it doesn't matter ... it sounds like you found a workable solution.
>
>Yes, it is just that I have to scan all the lines, after I have populated the string builder, to remove the LF character. Like I said, this does not happen on the first line but only on all upcoming ones.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform