?
Solved

String.split

Posted on 2009-07-10
6
Medium Priority
?
203 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 1000 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
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 
LVL 18

Assisted Solution

by:Gary Davis
Gary Davis earned 1000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

764 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