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.
您可以使用String.Split()
string[] words = @"e11*70/157*1999/101*1090*04".Split('*');
I think this should solve your ptoblem :
string content = @"11*70/157*1999/101*1090*04";
string [] split = words.Split('*');
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);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.