Solved

String.split

Posted on 2009-07-10
6
202 Views
Last Modified: 2012-05-07
How do I use the String.split method when the delimiter is a carrage return?  

Or, how do I use String.split with a string delimeter instead of a character delimiter?  So, in the case the delimiter would be  "\r"
0
Comment
Question by:dchau12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Accepted Solution

by:
satheeshm earned 250 total points
ID: 24827009
Hi..Try this

str2 = str1.Split('\n');
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 24827181
or you can use Environment.NewLine
0
 

Author Comment

by:dchau12
ID: 24827207
hey satjheeshm, str2 = str1.Split('\n');  does not work.  The delimiter is looking for a character.  A character is only one entry.  '\n' is a string.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Assisted Solution

by:Gary Davis
Gary Davis earned 250 total points
ID: 24827593
This does work. '\n' is a char not a string.

 

string str1="ss\nzz\n"; 
string[] str2 = str1.Split('\n');

Open in new window

0
 
LVL 18

Expert Comment

by:Gary Davis
ID: 24827603
Continued....
The str2 string array has three elements after the split. The last element is and empty string.
Gary Davis
0
 

Author Closing Comment

by:dchau12
ID: 31602257
I was dead wrong.  Good follow up gardavis.
0

Featured Post

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question