Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP.NET / VB / REGEX: Automatic Twitter Links

Posted on 2012-04-02
1
Medium Priority
?
508 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
[X]
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
1 Comment
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 37797933
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
Suggested Courses

618 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