|
Posted by Jochem Maas on 12/23/05 17:28
....
>>>
> 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
> }
>
Navigation:
[Reply to this message]
|