///
/// Given HTML overlay for an image in the store, render it.
/// [p:n] renders as price for item ID n
///
/// Rendere
You can only use the $1
notation if the replacement
argument is a string, so you ended up passing $1
as a literal string to the int.Parse
method.
Instead, use the (String, String, MatchEvaluator) overload with an anonymous method:
Regex.Replace(overlayHTML, pattern,
match => FormatCurrency(GetItemPriceOnDate(DateTime.Now, currencyID, int.Parse(match.Groups[1].Value)))
)
I'm not totally sure I understand you, so bear with me if I am off.
Console.WriteLine(int.Parse("$1")); //throws exception Input string was not in a correct format.
Console.WriteLine(int.Parse("$1".Replace("$", ""))); //Result: 1
If Store.CommonFunctions.GetItemPriceOnDate returns a string, you should be good to go.