Re: Simple String split
- From: "RobinS" <robins@xxxxxxxxxxxxxxxx>
- Date: Tue, 11 Mar 2008 21:16:31 -0700
"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message news:MPG.2241036cbccad724ad0@xxxxxxxxxxxxxxxxxxxxxxx
Pipo <nomail@xxxxx> wrote:String[] Channel = FileName.Split(new string[] { "\\r" },
StringSplitOptions.RemoveEmptyEntries);
The "\\r" should be "\r\n" there. Otherwise you'll only split strings
which actually contain a backslash followed by an r.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
If you don't know how the strings are "newlined", couldn't you test for \n, \r, and \r\n? This is how I do it. Note that the order of entries in crlfs is important.
string[] crlfs = { "\r\n", "\n", "\r" };
string[] lines = myText.Split(crlfs, StringSplitOptions.None);
RobinS.
GoldMail.com
.
- Follow-Ups:
- Re: Simple String split
- From: Jon Skeet [C# MVP]
- Re: Simple String split
- References:
- Simple String split
- From: AMP
- Re: Simple String split
- From: Pipo
- Re: Simple String split
- From: Jon Skeet [C# MVP]
- Simple String split
- Prev by Date: How can I convert System.Type variables to some database data type?
- Next by Date: Re: Retrieving items from a List<t>
- Previous by thread: Re: Simple String split
- Next by thread: Re: Simple String split
- Index(es):
Relevant Pages
|