2

I'm working on a program that will parse off chunks off data from a CSV file, and populate it into the attributes of an XML document. The data entry I'm working with looks like this...e11*70/157*1999/101*1090*04. I want to break that up, using the asterisks as the reference to split it into e11, 70/157, 1999/101, etc; so I can insert those values into the attributes of the XML. Would this be a situation appropriate for RegEx? Or would I be better off using Substring, with an index of *?

Thanks so much for the assistance. I'm new to the programming world, and have found sites such as these to be a extremely valuable resource.

3 Answers 3

5

You can use String.Split()

string[] words = @"e11*70/157*1999/101*1090*04".Split('*');
1
  • Thanks a lot, this was very helpful. I should be able to pull out those split values from the string array, right? May 10, 2011 at 18:56
0

I think this should solve your ptoblem :

string content = @"11*70/157*1999/101*1090*04";
     string [] split = words.Split('*');
1
  • Thanks a lot for the help, RaM, I really appreciate it. May 10, 2011 at 18:57
0

You could use the Split method to create a string array like so:

string txt = "e11*70/157*1999/101*1090*04";
foreach (string s in txt.Split('*')){
   DoSomething(s);
}
1
  • Thanks so much for the assist McMinton, I really appreciate it. May 10, 2011 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.