Re: Re: How to recognise url in a block of text

From: Date: Wed, 18 Oct 2006 16:24:39 +0000
Subject: Re: Re: How to recognise url in a block of text
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-243304@lists.php.net to get a copy of this message
On Wed, October 18, 2006 3:05 am, Ivo F.A.C. Fokkema wrote: '<(?:(?:https?)://(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::(?:(?:[0-9]*)))?(?:/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9\\-_.!~*\'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\\-_.!~*\'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)(?:/(?:(?:(?:[a-zA-Z0-9\\-_.!~*\'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\\-_.!~*\'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))(?:[?](?:(?:(?:[;/?:@&=+$,a-zA-Z0-9\\-_.!~*\'()]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)))?))?)>'; /^(ht|f)tps?:\/\/([0-9]{1,3}(\.[0-9]{1,3}){3}|([0-9a-z][-0-9a-z]*[0-9a-z]\.)+[a-z]{2,4})\/?[%&=#0-9a-z\/._+-]*\??.*$/i /((ht|f)tps?:\/\/([0-9]{1,3}(\.[0-9]{1,3}){3}|([0-9a-z][-0-9a-z]*[0-9a-z]\.)+[a-z]{2,4})\/?[%&=#0-9a-z\/._+-]*\??[^[:space:]]+)/i > It has worked fine for me, but I just can't read your regexp, so I > can't > see why it's better. For starters, I belive this URL will work for them, but not you: http://example.com:8080 I think you are also missing the new-fangled .musuem and other TLDs. I can't read PCRE well enough to say for sure for either of them, honestly. But I'd have to say that sucking down Perl's Common one that a zillion people are more or less happy with [*] is probably a better answer than rolling your own. [*] I'm under no illusion that there aren't a couple thousand Perl users arguing over this PCRE right this minute, but happiness is relative. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?

« previous php.general (#243304) next »