Re: Re: Filtering URLs problem..

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jochem Maas wrote:

...


Jochem's correct. I was in too big a hurry trying to help. It was


you don't mind if I forward that to my girlfriend? ;-) (the bit about me being correct)

obvious that Anders was not getting much useful help. His points 3 and 4


the lack of help is due to the fact that the problem is much easier to
explain/understand than to solve properly, and starting out with regular
expressions is a steep learning curve. that said I think the OP has plenty
of stuff to put his teeth into.

are valid and I was not addressing them because they require more work than I have time to devote.


fair enough :-)


Here is corrected code. It works with the "Regex Coach". I did not try it with a php script.

$types= (http|ftp|https|mms|irc);


I think there are a couple of single quotes missing in tyhe line above,
and the parentheses are probably meant to be square brackets:

$types= '[http|ftp|https|mms|irc]';


$pattern= "%<a\040href\040*=['\"]$types://((www.)*[\w/\.]+)['\"]>.+</a>%i"; // the "i" makes it non case sensitive

if(preg_match($pattern, $URL_str, $match)){

    $URL= match[2];
}

else{

    User did not enter a complete link; do the simple thing
}

..
 think there are a couple of single quotes missing in tyhe line above,

['\"] says either single or double quote.

and the parentheses are probably meant to be square brackets:

$types= '[http|ftp|https|mms|irc]'; Says: every "h" every "t" every "p" every "|"..... etc.

He needs (http|ftp|https|mms|irc); Which says "http" or "ftp" or https .... etc.

Note, I'm using $match[2], not $match[1].

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux