[PHP] How to recognise url in a block of text
Please, I need help on how to to recognise url in a block of text being retrieved from a database and present it as a link within that text. I will appreciate any help. Regards, Bunmi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Nicht gelesen: [PHP] How to recognise url in a block of text
I did not see any text in your mail. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to recognise url in a block of text
Hello, Thanks Toby. The aim is to show the entire text taken from the database (mysql) with the link within the text showing as a clickable link. Not just to remove entirely. Regards, Bunmi www.ayserve.net www.budelak.com Toby Osbourn wrote: Hello, I would suggest first of all splitting the block of text into single words (I would assume you would use " " as the delimiter for this assuming the text stored on the database is readable and not just random words delimited by something else). The use the eregi() function to see if any of the words contain either www. or http://www. If they do simply store them in an array or directly output them to your page. Regards Toby On 17/10/06, *AYSERVE.NET <http://AYSERVE.NET>* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote: Please, I need help on how to to recognise url in a block of text being retrieved from a database and present it as a link within that text. I will appreciate any help. Regards, Bunmi -- PHP General Mailing List ( http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.borninblood.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Empfangsbestätigung (angezeigt) - Re: [PHP] How to recognise url in a block of text
Sorry, I don't speak german. Regards, Bunmi www.ayserve.net, www.budelak.com [EMAIL PROTECTED] wrote: Dies ist eine Empfangsbestätigung für eine Nachricht, die Sie an [EMAIL PROTECTED] gesendet haben. Hinweis: Diese Empfangsbestätigung sagt nur aus, dass die Nachricht am Computer des Empfängers angezeigt wurde. Es gibt keine Garantie, dass der Empfänger die Nachrichteninhalte gelesen oder verstanden hat. Reporting-UA: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.0.7) Gecko/20060909 Thunderbird/1.5.0.7 Final-Recipient: rfc822;[EMAIL PROTECTED] Original-Message-ID: <[EMAIL PROTECTED]> Disposition: manual-action/MDN-sent-manually; displayed Return-path: <[EMAIL PROTECTED]> Envelope-to: [EMAIL PROTECTED] Delivery-date: Tue, 17 Oct 2006 10:17:06 +0200 Received: from lists.php.net ([216.92.131.4]) by mail.comtrance.net with esmtp (Exim 4.60) (envelope-from <[EMAIL PROTECTED]>) id 1GZk8H-sW-Ca for [EMAIL PROTECTED]; Tue, 17 Oct 2006 10:17:06 +0200 X-Host-Fingerprint: 216.92.131.4 lists.php.net Received: from [216.92.131.4] ([216.92.131.4:7357] helo=lists.php.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 16/03-04054-A1194354 for <[EMAIL PROTECTED]>; Tue, 17 Oct 2006 04:15:23 -0400 Received: (qmail 8561 invoked by uid 1010); 17 Oct 2006 08:15:16 - Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm Precedence: bulk list-help: <mailto:[EMAIL PROTECTED]> list-unsubscribe: <mailto:[EMAIL PROTECTED]> list-post: <mailto:php-general@lists.php.net> Delivered-To: mailing list php-general@lists.php.net Received: (qmail 8553 invoked by uid 1010); 17 Oct 2006 08:15:15 - Delivered-To: [EMAIL PROTECTED] Delivered-To: [EMAIL PROTECTED] Authentication-Results: pb1.pair.com [EMAIL PROTECTED]; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com [EMAIL PROTECTED]; sender-id=unknown Received-SPF: error (pb1.pair.com: domain ayserve.net from 70.84.85.66 cause and error) X-PHP-List-Original-Sender: [EMAIL PROTECTED] X-Host-Fingerprint: 70.84.85.66 bmw.websitewelcome.com Linux 2.6 Message-ID: <[EMAIL PROTECTED]> Disposition-Notification-To: "AYSERVE.NET" <[EMAIL PROTECTED]> Date: Tue, 17 Oct 2006 09:13:53 +0100 From: "AYSERVE.NET" <[EMAIL PROTECTED]> User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: Toby Osbourn <[EMAIL PROTECTED]>, php-general@lists.php.net References: <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> In-Reply-To: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bmw.websitewelcome.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - ayserve.net X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP] How to recognise url in a block of text -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to recognise url in a block of text
Thanks Alan. Retuen receipt disabled. Who can help regarding my problem below. I will appreciate any assistance. Regards, Bunmi www.ayserve.net., www.budelak.com AYSERVE.NET wrote: Hello, Thanks Toby. The aim is to show the entire text taken from the database (mysql) with the link within the text showing as a clickable link. Not just to remove entirely. Regards, Bunmi www.ayserve.net www.budelak.com Toby Osbourn wrote: Hello, I would suggest first of all splitting the block of text into single words (I would assume you would use " " as the delimiter for this assuming the text stored on the database is readable and not just random words delimited by something else). The use the eregi() function to see if any of the words contain either www. or http://www. If they do simply store them in an array or directly output them to your page. Regards Toby On 17/10/06, *AYSERVE.NET <http://AYSERVE.NET>* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote: Please, I need help on how to to recognise url in a block of text being retrieved from a database and present it as a link within that text. I will appreciate any help. Regards, Bunmi -- PHP General Mailing List ( http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.borninblood.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to recognise url in a block of text
Hello Robin, I love you man. The solution you gave below just worked perfectly fine. Thanks to all who assisted me on this. I appreciate you all. Regards, Bunmi www.ayserve.net www.budelak.com Robin Vickery wrote: On 17/10/06, Al <[EMAIL PROTECTED]> wrote: AYSERVE.NET wrote: > Please, I need help on how to to recognise url in a block of text being > retrieved from a database and present it as a link within that text. > > I will appreciate any help. > Regards, > Bunmi Show us some examples of URL substrings, with any variations, you want to handle. Most likely a regex function will do the job. In 6 easy steps: Step 1: Pinch a regexp from perl... perl -e 'use Regexp::Common; print $RE{URI}{HTTP}, "\n";' Step 2: Double up all backslashes M-x replace-string \ \\ Step 3: Escape single quote-marks M-x replace-string ' \' Step 4. modify slightly to cope with the https scheme by adding an optional 's' to the http scheme. Step 5. add angle-brackets as delimiters Step 6. use in a preg_replace() http://example.com imperdiet nec, tempus ac, purus. Suspendisse id lectus. Nam vitae quam. Aliquam ligula nisl, vestibulum vulputate, tempor nec, https://www.example.com tincidunt sit amet, libero. Suspendisse a justo. Cum sociis natoque penatibus et.'; $url_regexp = '<(?:(?: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]))*)))?))?)>'; $output = preg_replace($url_regexp, '$0', $textString); print $output; ?> If http and https isn't enough for you, there's another more general regexp but... well, it's 8.5Kb long. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to recognise url in a block of text
Hello Guys, I thought I was home and dry when the program worked fine on my windows but when I ran from my Linus server, I keep getting a url like: http://www.website.com/pdf/ED1.pdf%A0 instead of http://www.website.com/pdf/ED1.pdf. As a result, the link is not working. Please help. Regards, Bunmi www.ayserve.net www.budelak.com AYSERVE.NET wrote: Hello Robin, I love you man. The solution you gave below just worked perfectly fine. Thanks to all who assisted me on this. I appreciate you all. Regards, Bunmi www.ayserve.net www.budelak.com Robin Vickery wrote: On 17/10/06, Al <[EMAIL PROTECTED]> wrote: AYSERVE.NET wrote: > Please, I need help on how to to recognise url in a block of text being > retrieved from a database and present it as a link within that text. > > I will appreciate any help. > Regards, > Bunmi Show us some examples of URL substrings, with any variations, you want to handle. Most likely a regex function will do the job. In 6 easy steps: Step 1: Pinch a regexp from perl... perl -e 'use Regexp::Common; print $RE{URI}{HTTP}, "\n";' Step 2: Double up all backslashes M-x replace-string \ \\ Step 3: Escape single quote-marks M-x replace-string ' \' Step 4. modify slightly to cope with the https scheme by adding an optional 's' to the http scheme. Step 5. add angle-brackets as delimiters Step 6. use in a preg_replace() http://example.com imperdiet nec, tempus ac, purus. Suspendisse id lectus. Nam vitae quam. Aliquam ligula nisl, vestibulum vulputate, tempor nec, https://www.example.com tincidunt sit amet, libero. Suspendisse a justo. Cum sociis natoque penatibus et.'; $url_regexp = '<(?:(?: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]))*)))?))?)>'; $output = preg_replace($url_regexp, '$0', $textString); print $output; ?> If http and https isn't enough for you, there's another more general regexp but... well, it's 8.5Kb long. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to recognise url in a block of text
Wow, that was deep but I'll try to see to what you're saying. Bunmi www.ayserve.net www.budelak.com Robin Vickery wrote: On 18/10/06, AYSERVE.NET <[EMAIL PROTECTED]> wrote: Hello Guys, I thought I was home and dry when the program worked fine on my windows but when I ran from my Linus server, I keep getting a url like: http://www.website.com/pdf/ED1.pdf%A0 instead of http://www.website.com/pdf/ED1.pdf. I'd look at the text that you're working on rather than the regexp. It looks like some characterset conversion is going wrong - 0xA0 is the latin-1 non-breaking space character. I'm expect that on your linux machine that it's being converted to %0A at some point which is perfectly valid in a URL. But I'm just guessing. -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php