KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
This is my source string: <box><3> <table><1> <chair><8> This is my Regex Patern: <(?<item>\w+?)><(?<count>\d+?)> This is my Item class class Item { string Name; int count; //(...) } This is my Item Collection; List<Item> OrderList = new List(Item); I want to populate that list with Item's based on source string. This is my function. It's not working. Regex ItemRegex = new Regex(@"<(?<item>\w+?)><(?<count>\d+?)>", RegexOptions.Compiled); foreach (Match ItemMatch in ItemRegex.Matches(sourceString)) { Item temp = new Item(ItemMatch.Groups["item"].ToString(), int.Parse(ItemMatch.Groups["count"].ToString())); OrderList.Add(temp); } Threre might be some small mistakes like missing letter it this example because this is easier version of what I have in my app. The problem is that In the end I have only one Item in OrderList. UPDATE I got it working. Thans for help.
Tags (comma-separated)
Save Edits
Cancel