?
Solved

Find string and turn into hyperlink

Posted on 2013-02-06
5
Medium Priority
?
316 Views
Last Modified: 2013-02-06
I need to find URLs in some text, and then create hyperlinks.

Example Input:
You can find the answer at http://www.ask.com or you can try http://www.answers.com.

Example Output
You can find the answer at <a href='http://www.ask.com'>http://www.ask.com</a> or you can try <a href='http://www.ask.com'>http://www.answers.com</a>.
0
Comment
Question by:rrhandle8
[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
  • 2
  • 2
5 Comments
 
LVL 17

Expert Comment

by:Kent Dyer
ID: 38862599
Something like..  You will need to do some changing..

If instr(fieldname, "http://") Then
Replace (fieldname,"<a href='")
Else If instr(fieldname, ".com")
Replace (fieldname,".com</a>")
End If

Open in new window


here is a more complete example..
http://www.motobit.com/tips/detpg_replace-relative-links/

HTH,

Kent
0
 
LVL 31

Accepted Solution

by:
Wayne Barron earned 1240 total points
ID: 38862689
Here you go
http://ee.cffcs.com/Q_28023092/Q_28023092.asp
code
http://ee.cffcs.com/Q_28023092/Q_28023092.zip

The only thing is, that you have to have the
http://
at the beginning, in order for it to process it as a link.

Hope this helps.
Carrzkiss
0
 

Author Comment

by:rrhandle8
ID: 38862717
Carrzkiss,

Perfect, but a small flaw.  http://http//www.ask.com.

See the extra "http//"
0
 

Author Comment

by:rrhandle8
ID: 38862738
Here is how I fixed it.
' create anchors from URLs
' Updated by Wayne Barron on 2/07/2013
' This first one, will allow you to only write the url, without the http://

Commented out this line
' Text = regEx.Replace(Text, "<a href=""http://$1"">$1</a>")

' This one, you have to provide the http:// in order to process it as a URL
Text = regEx.Replace(Text, "<a href=""$1"">$1</a>")
0
 
LVL 31

Expert Comment

by:Wayne Barron
ID: 38862794
Yea, I was trying something and THOUGHT that I had it working, and jumped the gun and uploaded the newer copy.
However, if you download it now, it is the original code, as I could not get the other one working.
Which was, to make it so you did not have to type in the http://
However, I thought it worked, but it did not.
So, that was the reason for the http:// being embedded in the code like it was.

Have a good one.
Carrzkiss
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

770 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