Re: URL parsing [was Re: "+" and "-" are numbers.]
Re: URL parsing [was Re: "+" and "-" are numbers.]
- Subject: Re: URL parsing [was Re: "+" and "-" are numbers.]
- From: has <email@hidden>
- Date: Tue, 6 Aug 2002 14:47:59 +0100
Nigel Garvey wrote:
>
>> What can you do in the area of URL parsing? ;-)
>
>
>
>You mean extracting URLs from a larger string? Well, it ain't easy.
>
>
Here's something that needs to be developed (and optimised) by someone
>
with more knowledge of URL protocols than myself. It only *extracts*
>
candidate URL's. It doesn't test their validity or try to standardise
>
their cases. One or two of the lines are quite long, but the line wraps
>
should be obvious:
>
>
on extractURLs from str
[...]
>
end extractURLs
>
>
set str to "This is a string containing the URL:
>
<www.fred.com/>.
>
It's nice, isn't it? Also:
>
mailto:email@hidden."
>
>
extractURLs from str
>
--> {"http://www.fred.com/", "mailto:email@hidden"}
Alas, this makes various assumptions that cannot be relied on in practice:
the presence of a "www." substring; case; that addresses will be shown
neatly delimited by "<>".
Also, I'd recommend treating email addresses separately than mixing them in
with URL extraction [1].
But, as I said before, it ain't easy... ;)
Cheers,
has
[1] I'd be happy to post you my email extractor if you'd like something to
thrash in return; currently there's one known bug and a possible problem
I'm not sure about... you'd be welcome to try and find more.:)
--
(My email address has changed from <email@hidden> to
<email@hidden>. Please update your address books accordingly.)
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.