You are here: Re: Find urls in plain text files « PHP Programming Language « IT news, forums, messages
Re: Find urls in plain text files

Posted by Sanders Kaufman on 11/02/07 20:15

"Salve Hεkedal" <ikkjespam.salve@slogedalen.no> wrote in message
news:2-2dnSvk0Nk307baRVnzvQA@telenor.com...
> On 2007-11-02, Christoph Burschka <christoph.burschka@rwth-aachen.de>
> wrote:

>> The following expression should find strings that satisfy these
>> conditions:
>>
>> - optionally a http protocol identifier
>> - optionally a username(:password)@ string, which allows pretty much any
>> characters except for spaces and colons. This isn't RFC-standard, by the
>> way.
>> - a hostname consisting of at least two and at most 34 labels, the last
>> of which
>> has 2 to 5 alphabet letters (for weird new ones like aero and museum; you
>> can
>> shorten it to 3 and still get the most common ones).
>> - optionally a path containing any characters apart from spaces, and
>> /ending in
>> a non-punctuation character/. This last bit is vital because it avoids
>> messing
>> up URLs at the end of a sentence.
>>
>> (http:\/\/)?([^ :]+(:[^
>> ]+)?@)?[a-z0-9]([a-z0-9i\-]{0,61}[a-z0-9])?(\.[a-z0-9]([a-z0-9\-]{0,61}[a-z0-9])?){0,32}\.[a-z]{2,5}(\/[^
>> ]*[^" \.,;\)])?
>>
>> (linebreaks are added by email client)
>>
>> This is a case insensitive pattern, you'll need the i modifier.
>>
>> --
>> Christoph Burschka
>
> Thanks alot! I'll study this closely

Does it make your eyes and ears bleed,the way it does mine?
Been doin this stuff since the 70's - but regex still makes me cry.

On that note, I am at the moment, writing a function that could sure benefit
from some regex.
I just want to see if a string starts with "http(s)://", "news:", "mailto:",
"ftp:".
That's a pretty simple regex, right?
Hoooowwww?

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация