in reply to Re: Re: Re: Regex to match file extension in URL
in thread Regex to match file extension in URL

Let me break this down and learn :)
\. # literal period ( # start capture [^.] # any character that's not...any character? + # one or more of them ) # stop capture $ # end of line
I don't get [^.]. 'Splain? :)

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Regex to match file extension in URL
by Trimbach (Curate) on Sep 09, 2001 at 19:07 UTC
    You got it right, except for the negated character class. Because the metacharacter "." is meaningless inside a character class (because "." and [.] would be the same thing) the period means a literal period inside a character class. So the regex is actually:
    \. # literal period ( # start capture [^.] # any character that's not a period + # one or more of them ) # stop capture $ # end of line
    This guarantees that you'll get the last chunk of non-periods at the end of URL... but beware because like I said "http://www.yahoo.com" will match "com", and "http://www.somewhere.com/home/" will match "com/home/".

    Gary Blackburn
    Trained Killer