using System.Text.RegularExpressions;
public static class ClipboardFusionHelper
{
public static string ProcessText(string text)
{
text = Regex.Replace(text,
@"(https?://www\.google\.[a-z.]+/search)(?(?=\?tbm=)(\?(tbm=[^&\s]*).*?(&q=[^&\s]*))|((?=.*?[?&](q=[^&\s]*))(?=.*?(&tbm=[^&\s]*))*))[a-zA-Z0-9-_./~*%$@:;,!?&=+#]*",
"$1?$2$3$5$6");
text = Regex.Replace(text,
@"(https?://maps\.google\.[a-z.]+/maps)(?(?=\?q=)(\?(q=[^&\s]*)(?=.*?(&(?:s?ll|z|t)=[^&\s]*))*)|((?=.*?[?&](q=[^&\s]*))(?=.*?(&(?:s?ll|z|t)=[^&\s]*))*))[a-zA-Z0-9-_./~*%$@:;,!?&=+#]*",
"$1?$2$3$5$6");
text = Regex.Replace(text,
@"(https?://www\.youtube\.com/watch).*?[?&](v=[^&\s]*)[a-zA-Z0-9-_./~*%$@:;,!?&=+#]*",
"$1?$2");
text = Regex.Replace(text,
@"(https?://www\.amazon\.[a-z.]+).*?(/(dp|gp/product|exec/obidos/ASIN)/[A-Z0-9]+)[a-zA-Z0-9-_./~*%$@:;,!?&=+#]*",
"$1$2/");
return text;
}
}