Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

ASP.NET / VB: Automatically create email links from a static text

Posted on 2012-03-23
1
482 Views
Last Modified: 2012-08-13
Using ASP.NET / VB, how can I automatically create email links from a static text?

The following code works in PHP but I need it converted to ASP.NET / VB.

<?php

function emailize($text) {
  $regex = '/(\S+@\S+\.\S+)/i';
  $replace = "<a href='mailto:$1'>$1</a>";
  $result = preg_replace($regex, $replace, $text);
  return $result;
}

echo emailize ("Hello World me@example.com Test 123 xyz@example.com");

?>

Open in new window

0
Comment
Question by:hankknight
1 Comment
 
LVL 13

Accepted Solution

by:
Pryrates earned 500 total points
ID: 37760092
you an use a function like:
   Protected Function emailize(ByVal input As String) As String
        Return RegularExpressions.Regex.Replace(input, "(\S+\@\S+\.\S+)", "<a href='mailto:$1'>$1</a>")
    End Function

Open in new window


you can call it within your page like:
<%=emailize("Hello World me@example.com Test 123 xyz@example.com")%>

Open in new window


Hope that helps
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question