Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by Amoe (Friar)
on Sep 09, 2001 at 17:15 UTC ( [id://111278]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://111278]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found