I'll start by saying that all backslashes are there to escape the next
character. For the rest
/               start js regexp
^               start of string
https?          http with optional s
:\/\/           ://
[-a-z0-9]+      one or more letters, digits or hyphen
(hyphen as first char so you don't need to escape)
(\.[-a-z0-9]+)* zero ore more groups starting with a dot
                folowed by characters (same class as above)
\.([a-z]{2,3}|aero|coop|info|museum|name)
                extension: 2 or 3 letters or one of list
\/?             Optional trailing slash
$               end of string
/I              end of regexp (i for case-insensitive)

HTH
Pascal
> -----Original Message-----
> From: Charlie Griefer [mailto:[EMAIL PROTECTED]
> Sent: woensdag 3 maart 2004 16:17
> To: CF-Talk
> Subject: Re: _javascript_ to Check link format...
>
> would anybody mind breaking this down for those of us who are
> working on picking up regex?
>
> > From: Pascal Peters [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, March 03, 2004 8:27 AM
> > To: CF-Talk
> > Subject: RE: _javascript_ to Check link format...
> >
> > function checkURL(url){
> > var pattern =
> >
> /^https?:\/\/[-a-z0-9]+(\.[-a-z0-9]+)*\.([a-z]{2,3}|aero|coop|info|mus
> > eu
> > m|name)\/?$/i;
> > return pattern.test(url);
> > }
>
> what i have and where i get stuck:
>
> I'll start off with saying I have no idea what the first two
> characters represent here (I thought the caret was a negation
> operator...but I guess that's just in []).  then of course,
> we have the http with the optional s.
> two (escaped) slashes.  then any combination of letters or
> numbers (altho i'm a bit fuzzy on the - in front of the
> a-z...does that negate case sensitivity?).  a dot (escaped),
> once again followed by any combination of letters or numbers.
>  I'm not sure about the asterisk...or why the second set of
> 'any combination of letters or numbers' gets grouped in parentheses.
> Once again, an escaped dot, followed by any letter combo of
> 2-3 letters, or any of the specified tlds.  not sure about
> the /?$/i at the end.
>
> any clarification on where I'm stuck (or corrections on where
> I'm wrong) would be appreciated.
>
> Charlie
>
>
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to