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

x
?
Solved

link parser

Posted on 2004-10-22
8
Medium Priority
?
231 Views
Last Modified: 2008-03-06
hello,
I need some code that will parse some text and change all the URLs to clickable links.  The qystem will be very simular to EE's:

examples that it needs to identify:

http://www.google.com
http://google.com
www.google.com

The script will also need to change links that are for the site into links also.  Example:

http:help.html
http://help.html

http:Q_10000000.html
http://Q_10000000.html

http:#10000000
http://#10000000

all the numbers will be 8 digits long, if that is needed for the script.  The problem I have had with other scripts is that the script puts a / after the URL for the "special" URLs (the last ones listed).  I assume this would only require a slight modification to any of the numerious link parsing scripts out there.

Thanks!
Matt
0
Comment
Question by:mattjp88
[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
  • 3
  • 2
8 Comments
 
LVL 8

Expert Comment

by:sigmacon
ID: 12386783
Please post one of the scripts that came the closest to what you wanted to do, and then we can tinker with it.
0
 
LVL 6

Author Comment

by:mattjp88
ID: 12386785
sorry, I just got thinking and playing, and got it to work.  woo hoo!

requesting delete.

Thanks!
0
 
LVL 8

Expert Comment

by:sigmacon
ID: 12386867
delete / refund is fine
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:andYetAnotherLoginName
ID: 12402110
no, no, I object. Let us see the solution :)
0
 
LVL 8

Expert Comment

by:sigmacon
ID: 12402194
OK, YOU MUST SHOW THE SOLUTION, OR WE WILL FIND YOU AND GET IT FROM YOU - AND GIVE MY POINTS - WAH HA HA HA HA ... no, seriously, I don't care.
0
 
LVL 6

Accepted Solution

by:
mattjp88 earned 0 total points
ID: 12403432
>Mod
PAQ/Refund please....

the solution:

function linkParser($str) {

  $str = eregi_replace("([[:space:]])((f|ht)tps?:\/\/[a-z0-9~#%@\&:=?+\/\.,_-]+[a-z0-9~#%@\&=?+\/_-]+)", "\\1<a href=\"\\2\">\\2</a>", $str); //http
  $str = eregi_replace("([[:space:]])(www\.[a-z0-9~#%@\&:=?+\/\.,_-]+[a-z0-9~#%@\&=?+\/_-]+)", "\\1<a href=\"http://\\2\">\\2</a>", $str); // www.
 
  $str = eregi_replace("^((f|ht)tp:\/\/[a-z0-9~#%@\&:=?+\/\.,_-]+[a-z0-9~#%@\&=?+\/_-]+)", "<a href=\"\\1\">\\1</a>", $str); //http
  $str = eregi_replace("^(www\.[a-z0-9~#%@\&:=?+\/\.,_-]+[a-z0-9~#%@\&=?+\/_-]+)", "<a href=\"http://\\1\">\\1</a>", $str); // www.

  $str = eregi_replace("([[:space:]])(http:[a-z0-9~#%@&:=?/\+.,_-]+[a-z0-9~#%@&=?/\+_-]+)", "<a href=\"\\2\">\\2</a>", $str); //local links
 
  return $str;
}
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

636 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