Solved

ASP.NET / VB / REGEX: Automatic Twitter Links

Posted on 2012-04-02
1
501 Views
Last Modified: 2012-08-13
Using ASP,NET, VB and REGEX, I want to automatically create twitter links from this:
(@xyz) where xyz is the twitter username.

The problem with the code below is that it returns this:
<a href="http://twitter.com/(@WWF)">(@WWF)</a>.

instead of this:
(<a href="http://twitter.com/WWF">@WWF</a>).

input = RegularExpressions.Regex.Replace(input, "(?<!\S)(\(@\S+[^\s\)]+\S)", "<a href=""http://twitter.com/$1"">$1</a>")

Open in new window

0
Comment
Question by:hankknight
1 Comment
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
Comment Utility
Try this:

input = RegularExpressions.Regex.Replace(input, "(?<!\S)\((@)(\S+[^\s\)]+)\)", "<a href=""http://twitter.com/$2"">$1$2</a>")

Open in new window

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now