FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old December 13th, 2003, 09:36 PM
edman007's Avatar
edman007 edman007 is offline
Trapped on the forums...help
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Aug 2003
Location: /Users/edman007
Posts: 4,617 edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)  Folding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate Folder
Time spent in forums: 1 Month 3 Weeks 3 Days 4 h 34 m 24 sec
Reputation Power: 787
Send a message via AIM to edman007
PCRE--match that don't have http://, https://, or ftp://

i have been working on this for hours and have looked everywhere, i just can figure out how do i match the urls in the <a > tags in some html if it doesn't have an http of ftp protocol

i want it to match things like this

<a href="list.php">
<a href="httpphp.php">

but not this

<a href="http://site.com" >

here is what i got so far
Code:
preg_match('/<a(.*?)href(\s)*=(\s)*(\'|")*(http:\/\/|https:\/\/|ftp:\/\/){0}(.*?)(\'|")*(.*?)>/i',$html);

but this will match all examples i put above

EDIT:::
fixed the escape charcters

Last edited by edman007 : December 13th, 2003 at 09:56 PM.

Reply With Quote
  #2  
Old December 13th, 2003, 09:44 PM
scoutt's Avatar
scoutt scoutt is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2001
Posts: 645 scoutt Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 16 sec
Reputation Power: 0
the php code tags strip the slashes form it, you have to use the [code] tags.

do this instead
PHP Code:
 $link "<a href=\"list.php\">";
if(
ereg("https|http|ftp"$link)){
    
// do something if it matches
   // or do the oppostie.


Reply With Quote
  #3  
Old December 13th, 2003, 09:49 PM
realnowhereman realnowhereman is offline
Not there when you need me
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2001
Location: Berlin, Germany
Posts: 1,438 realnowhereman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 46 sec
Reputation Power: 8
<a href="ftp-servers.html" />

Reply With Quote
  #4  
Old December 13th, 2003, 09:55 PM
edman007's Avatar
edman007 edman007 is offline
Trapped on the forums...help
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Aug 2003
Location: /Users/edman007
Posts: 4,617 edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)  Folding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate Folder
Time spent in forums: 1 Month 3 Weeks 3 Days 4 h 34 m 24 sec
Reputation Power: 787
Send a message via AIM to edman007
i don't think i can do that, i am editing all the <a href="blah" > tags in an html page and i'm going to use preg_replace() (unless there is an easier way), and have to do different things if it doesn't have the protocol, also i want it to match blah.php?http://blah i only want it to not match it if it is the first part of the url

Reply With Quote
  #5  
Old December 14th, 2003, 08:47 AM
edman007's Avatar
edman007 edman007 is offline
Trapped on the forums...help
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Aug 2003
Location: /Users/edman007
Posts: 4,617 edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)  Folding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate Folder
Time spent in forums: 1 Month 3 Weeks 3 Days 4 h 34 m 24 sec
Reputation Power: 787
Send a message via AIM to edman007
so dose anyone know how to do this?

Reply With Quote
  #6  
Old December 14th, 2003, 10:08 AM
Fataqui Fataqui is offline
Senior Member
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2001
Location: Boston Ma.
Posts: 1,530 Fataqui User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 42 sec
Reputation Power: 0
Hi

If your wanting to match all of these then why not use preg_match_all, it will give you more control....


Example.....

PHP Code:
<?
$file 
file_get_contents('http://forums.devshed.com/t105636/s.html');
preg_match_all('!(<a href=(\\\\'|")?(http|ftp)?(s)?(.*?)(\\\\'|")?>)!is', $file, $matches);
$links = array();
for($i = 0; $i < sizeof($matches[3]); $i++){
if(empty($matches[3][$i])){
$links[] = $matches[0][$i];
}
}
unset($matches);
print_r($links);
?>



You can refine the preg_match_all, I just did it quick for the example!


F!

Reply With Quote
  #7  
Old December 14th, 2003, 10:27 AM
edman007's Avatar
edman007 edman007 is offline
Trapped on the forums...help
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Aug 2003
Location: /Users/edman007
Posts: 4,617 edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)  Folding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate Folder
Time spent in forums: 1 Month 3 Weeks 3 Days 4 h 34 m 24 sec
Reputation Power: 787
Send a message via AIM to edman007
i want to match just the ones that don't start with ftp://, http:// or https:// so it can be used in preg_replace(); i don't know how i would use preg_match_all to do this

here is what i am using, now, i just have to get the match part right

PHP Code:
 $page preg_replace('/<a(.*?)href(\\s)*=(\\s)*(\\'|")*(http|https|ftp){0}(.*?)(\'|")*(.*?)>/i',
    '
<a1href2=34'.$this_page.'?url='.$url_parts['scheme'].'://'.$url_parts['host'].$path_parts['dirname'].'/\\6\\7\\8>',$page); 


edit---had to escape the escape things

Last edited by edman007 : December 14th, 2003 at 10:30 AM.

Reply With Quote
  #8  
Old December 14th, 2003, 10:29 AM
Fataqui Fataqui is offline
Senior Member
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2001
Location: Boston Ma.
Posts: 1,530 Fataqui User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 42 sec
Reputation Power: 0
Hi


Did you try my example?


F!

Reply With Quote
  #9  
Old December 14th, 2003, 10:41 AM
edman007's Avatar
edman007 edman007 is offline
Trapped on the forums...help
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Aug 2003
Location: /Users/edman007
Posts: 4,617 edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)  Folding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate Folder
Time spent in forums: 1 Month 3 Weeks 3 Days 4 h 34 m 24 sec
Reputation Power: 787
Send a message via AIM to edman007
i'm just getting an empty array

i want it to replace as i showed above, i can't get it to do that with what you gave me

Reply With Quote
  #10  
Old December 14th, 2003, 10:44 AM
Fataqui Fataqui is offline
Senior Member
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2001
Location: Boston Ma.
Posts: 1,530 Fataqui User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 42 sec
Reputation Power: 0
Hi


Look at view source, not the browser output!



F!

Reply With Quote
  #11  
Old December 14th, 2003, 10:50 AM
ChibiGuy's Avatar
ChibiGuy ChibiGuy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: USA
Posts: 470 ChibiGuy User rank is Lance Corporal (50 - 100 Reputation Level)ChibiGuy User rank is Lance Corporal (50 - 100 Reputation Level)ChibiGuy User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 8 h 30 m 50 sec
Reputation Power: 6
Send a message via AIM to ChibiGuy
try
PHP Code:
if ( !preg_match('/^(http(s)?:\\/\\/|ftp:\\/\\/)/i'$string) )
{
  
// ...

it matches any string with no http://, https://, or ftp:// in the beggining of it.

Reply With Quote
  #12  
Old December 14th, 2003, 10:53 AM
edman007's Avatar
edman007 edman007 is offline
Trapped on the forums...help
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Aug 2003
Location: /Users/edman007
Posts: 4,617 edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)edman007 User rank is Major General (70000 - 90000 Reputation Level)  Folding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate FolderFolding Points: 67263 Folding Title: Intermediate Folder
Time spent in forums: 1 Month 3 Weeks 3 Days 4 h 34 m 24 sec
Reputation Power: 787
Send a message via AIM to edman007
i did a print_R of both $matches and $links and here is what i get

Code:
Array
(
    [0] => Array
        (
        )

    [1] => Array
        (
        )

    [2] => Array
        (
        )

    [3] => Array
        (
        )

    [4] => Array
        (
        )

    [5] => Array
        (
        )

    [6] => Array
        (
        )

    [7] => Array
        (
        )

    [8] => Array
        (
        )

)
Array
(
)


there is nothing there and nothing that can point me in the right direction on what to change

Reply With Quote
  #13  
Old December 14th, 2003, 11:08 AM
Fataqui Fataqui is offline