|
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]
|