private string ResponseClean(string response)
{
Regex reg = new Regex(@"translatedText.{3}(?<translatedText>[^}]+)""}");
Match match = reg.Match(response);
string cleanedResponse = match.Groups["translatedText"].Value;
cleanedResponse = HttpUtility.HtmlDecode(cleanedResponse.Replace(@"\u0026", "&"));
cleanedResponse = cleanedResponse.Replace(@"\", "");
if (cleanedResponse.Contains("detectedSourceLanguage")) {
cleanedResponse = cleanedResponse.Remove(cleanedResponse.LastIndexOf("detectedSourceLanguage") - 3);
}
if (_debug) logger.Debug("Translation tool: Cleaned Translation: {0}", cleanedResponse);
return cleanedResponse;
}