User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,709 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,389 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2750 | Replies: 6
Reply
Join Date: Mar 2004
Location: In a house
Posts: 94
Reputation: Ragnarok is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
Ragnarok Ragnarok is offline Offline
Junior Poster in Training

Scanning for links

  #1  
Jun 1st, 2004
I'm trying to make a BB Code script, setting the Bold, Italic, URL etc is easy enought but how do you make it scan for rogue links that aren't placed in a URL tag and same goes for email because I just can't get it to work.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2003
Location: London, England
Posts: 281
Reputation: Roberdin will become famous soon enough Roberdin will become famous soon enough 
Rep Power: 7
Solved Threads: 6
Colleague
Roberdin Roberdin is offline Offline
Supreme Evil Overlord

Re: Scanning for links

  #2  
Jun 1st, 2004
htmlentities()
Reply With Quote  
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,881
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 32
Solved Threads: 108
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Scanning for links

  #3  
Jun 1st, 2004
Hey rob! Can you explain to me how that's used please?
Reply With Quote  
Join Date: Mar 2004
Location: In a house
Posts: 94
Reputation: Ragnarok is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
Ragnarok Ragnarok is offline Offline
Junior Poster in Training

Re: Scanning for links

  #4  
Jun 4th, 2004
Thats now what I mean, I want to be able to detect a plain text URL strait out of some text for example what forums do:

http://www.squarehybrid.com

you will note that I have not placed the [url] tags around them the link has been activated.
Reply With Quote  
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,881
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 32
Solved Threads: 108
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

Re: Scanning for links

  #5  
Jun 4th, 2004
I'm not exactly sure of the PHP code to do this, but the algorithm might be for a string X, search the string until you detect "http://" ... from that on, it is a link until you reach whitespace. For each letter that isn't part of the URL, copy it directly into a new string X2. When you do detect a URL, add the appropriate code before and after it, and then copy it into X2. I think that might be a lot easier than inserting into the middle of the original string. I'm not sure how flexible php is with strings compared to C++ and Java, for example. Since it is a scripting language, however, I would assume it would natively be built to handle strings very well.
Reply With Quote  
Join Date: Feb 2003
Location: London, England
Posts: 281
Reputation: Roberdin will become famous soon enough Roberdin will become famous soon enough 
Rep Power: 7
Solved Threads: 6
Colleague
Roberdin Roberdin is offline Offline
Supreme Evil Overlord

Re: Scanning for links

  #6  
Jun 4th, 2004
Oh you could use preg_replace() with some regular expression trickery...

www.php.net/preg-replace
www.regular-expressions.info
Reply With Quote  
Join Date: Mar 2004
Location: In a house
Posts: 94
Reputation: Ragnarok is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
Ragnarok Ragnarok is offline Offline
Junior Poster in Training

Re: Scanning for links

  #7  
Jun 5th, 2004
look at all the PHP functions avalable for doing something like this I have only found two that should work. They are preg_replace and eregi_replace but I only know the basics of how they work. for example

[php]$text = preg_replace("#\[b\](.+?)\[/b\]#i","<b>\\1</b>",$text);[/php]

that would take what ever the value of text is and if it finds [b] (in eather case) it will make the string that is inside bold.

I have looked at the PHP's preg syntaxs (sp) and I don't understand how they work well enough to know what to do.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 1:55 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC