Con el siguiente método podremos convertir en hipervínculos (enlaces) todas las direcciones URL encontradas en una cadena de texto, que será pasada como parámetro al método.
public String getLinks(String text)
{
String pattern;
pattern = @»(http://([w.]+/?)S*)»;
Regex re = new Regex(pattern,RegexOptions.IgnoreCase | RegexOptions.Compiled);
text = re.Replace(text, «<a href=»$1″» target=»»_blank»»>$1</a>»»);
return text;
}
{
String pattern;
pattern = @»(http://([w.]+/?)S*)»;
Regex re = new Regex(pattern,RegexOptions.IgnoreCase | RegexOptions.Compiled);
text = re.Replace(text, «<a href=»$1″» target=»»_blank»»>$1</a>»»);
return text;
}