【发布时间】:2014-01-03 16:59:38
【问题描述】:
以下是我目前拥有的代码,但它没有按我的意愿工作,所以我需要一些帮助。
字符串[] FCVs 带有字符串...每个看起来有点像 $103,700</td><t 但数字不同。
我想让这些数字以整数形式返回。
该函数返回一个列表,因为第一项 Description 是一个字符串。
public static List<object> processPage(string sourceCode)
{
List<object> ItemsToReturn = new List<object>();
string Description = getBetween(sourceCode, @"Description:</td><td style=""padding-top: 5px; padding-bottom: 5px; font-size: 8pt; vertical-align: top;"">", "</td>");
ItemsToReturn.Add(Description);
string FullCashValue = getBetween(sourceCode, @"Full Cash Value</a>", "<a href");
string[] FCVs = new string[2];
int index1 = FullCashValue.IndexOf("$");
FCVs[0] = FullCashValue.Substring(index1, 15).ToString(); //2014
int index2 = FullCashValue.IndexOf("$", index1 + 1);
FCVs[1] = FullCashValue.Substring(index2, 15).ToString(); //2013
int[] int_FCVs;
for (int i = 0; i < FCVs.Count(); i++)
{
Match m = Regex.Match(FCVs[I], @"[+-]?\d*\.?\d+([Ee][+-]?\d+)?");
int_FCVs[i] = m.Value;
}
foreach (int FCV in int_FCVs)
{
ItemsToReturn.Add(FCV);
}
}
【问题讨论】:
-
你在问什么?你有什么问题?
标签: c# regex arrays string int