C
Craig Dunstan
I would like to dynamically build a list of arguments to pass the
string.Format method and I am not sure how to do it.
Basically, I would like to dynamically build a list based on the results of
a regular expression match ie:
private string[] FormatContent(string pContent, string pExpression, pFormat)
{
Regex p = new Regex(pExpression, RegexOptions.SingleLine);
MatchCollection matches = p.Matches(pContent);
string[] result = new string[matches.Count];
for (int i=0; i<matches.Count; i++)
{
// build a dynamic params list to pass to the format, let's call it
"paramlist" from
for (int j=0; j<matches.Groups.Count; j++)
{
// add matches.Groups[j].Value to the dynmic paramlist...
????
}
result = string.Format(pFormat, ?paramlist?)
}
// now give the result back.....
return( result );
}
string.Format method and I am not sure how to do it.
Basically, I would like to dynamically build a list based on the results of
a regular expression match ie:
private string[] FormatContent(string pContent, string pExpression, pFormat)
{
Regex p = new Regex(pExpression, RegexOptions.SingleLine);
MatchCollection matches = p.Matches(pContent);
string[] result = new string[matches.Count];
for (int i=0; i<matches.Count; i++)
{
// build a dynamic params list to pass to the format, let's call it
"paramlist" from
for (int j=0; j<matches.Groups.Count; j++)
{
// add matches.Groups[j].Value to the dynmic paramlist...
????
}
result = string.Format(pFormat, ?paramlist?)
}
// now give the result back.....
return( result );
}