How开发者_高级运维 can I extract the decimal part of a string that has an equals sign as the delimiter?
Example:
2 = No
10 = (6 - 8 hrs/day, Good & Restful)
1 = low in fat 1 = low in sugar 1 = high in fiber
Someone please help. Thanks.
The following C# code will return number that is located in the left of the equal sign into an integer list given a string "input":
// string input = "<your input>";
Match m = Regex.Match(input, @"\s*(?<dec>\d+)\s*=");
List<int> intList = new List<int>();
while (m.Success)
{
intList.Add(Int32.Parse(m.Groups["dec"].Value));
m = m.NextMatch();
}
// Process intList
精彩评论