问题
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.
回答1:
You can use String.Split()
string[] words = @"e11*70/157*1999/101*1090*04".Split('*');
回答2:
I think this should solve your ptoblem :
string content = @"11*70/157*1999/101*1090*04";
string [] split = words.Split('*');
回答3:
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);
}
来源:https://stackoverflow.com/questions/5951114/how-can-i-split-a-string-between-multiple-delineating-characters