日期:2014-05-17 浏览次数:20984 次
public string[] Analyze(string input)
{
input = input.Replace(" ",string.Empty);
Regex regclearbracket = new Regex(@"\(([^(]+?)\)");
Regex regclearcomma = new Regex(@"([,\d\$]+\*[,\d\$]+)");
MatchEvaluator evalclearbracket = new MatchEvaluator(RepClearBracket);
MatchEvaluator evalclearcomma = new MatchEvaluator(RepClearComma);
while (regclearbracket.IsMatch(input))
{
input = regclearbracket.Replace(input, evalclearbracket);
while (regclearcomma.IsMatch(input))
input = regclearcomma.Replace(input, evalclearcomma);
}
return input.Replace("$","*").Replace(",","+").Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries);
}
public string RepClearBracket(Match m)
{
return m.Groups[1].Value.Replace("+", ",").Replace("*","$");
}
public string RepClearComma(Match m)
{
cs c = new cs(m.Groups[1].Value.Split(new char[] { '*' }, StringSplitOptions.RemoveEmptyEntries));
return c.ToString();
}
public class cs
{
public cs(string[] c)
{
l = c[0].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
&