我该如何分割多描绘字符之间的字符串? [英] How can I split a string between multiple delineating characters?
问题描述
我工作的一个程序,将解析掉块关闭数据从一个CSV文件,并填充到XML文档的属性。数据输入我与这个样子的...... E11 *一百五十七分之七十零*101分之1999* 1090 * 04。我想打破了,用星号作为参考将其分割成E11,一百五十七分之七十〇,第1999/101号等;所以我可以将这些值转换为XML的属性。这将是这种情况适用于正则表达式?我会不会更好使用子串,用的指数*?
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('*');
这篇关于我该如何分割多描绘字符之间的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!