This is my first post in this forum. I have text with in double which i want to replace by another text.
This is my full text
"Operational Metrics~Copper C1 Cash Costs (US$/lb) - Lalor~9999"*"Operational Metrics~Canadian Dollars (Canadian $/US$)~9999"
This text "Operational Metrics~Copper C1 Cash Costs (US$/lb) - Lalor~9999" will be replace with excel cell address A10.
I have tried this way but not being able to replace the text within double quote. surely there is problem in my code which i am not able to fix.
string mainstr = "\"" + "Operational Metrics~Copper C1 Cash Costs (US$/lb) - Lalor~9999" + "\"" + "*" + "\"" + "Operational Metrics~Canadian Dollars (Canadian $/US$)~9999" + "\"";
string replacesfrom = "\"" + "Operational Metrics~Copper C1 Cash Costs (US$/lb) - Lalor~9999" + "\"";
string replacesto = "A10";
string afterreplace = Regex.Replace(mainstr, replacesfrom, replacesto);
Desired output will be.
"A10"*"Operational Metrics~Canadian Dollars (Canadian $/US$)"
I tried this logic too but still no luck.
public static string ReplaceWholeWord(this string original, string wordToFind, string replacement, RegexOptions regexOptions = RegexOptions.None)
{
string pattern = String.Format(@"\b{0}\b", wordToFind);
string ret = Regex.Replace(original, pattern, replacement, regexOptions);
return ret;
}
with above function i try to replace but unfortunately not being able to replace text Operational Metrics~Copper C1 Cash Costs (US$/lb) - Lalor with A10
Please suggest what to change in my above code.