http://qs321.pair.com?node_id=967486


in reply to Extracting Page Name

The something simple may be that the 'pagename' will follow the last slash.

The catch: it may be followed by many options -- a colon, Note_1 if it's followed by a port number; a questionmark for several possible uses; and perhaps others that I'm blanking on just now. But regardless, the entity from the last slash, through a period to the next punctuation should be what you're looking for.

And to broaden the hint a bit further, the regex documentation and tutorials here will show you precisely the way to obtain what you're looking for.

Update: Note_1 See correction (+ + by quester immediately below. Aargh.

Replies are listed 'Best First'.
Re^2: Extracting Page Name
by quester (Vicar) on Apr 27, 2012 at 06:34 UTC

    ... a colon, if it's followed by a port number...

    Minor nit: The colon and port number is just after the hostname in a URL, not the page name. For example, consider the port 8080 in

    http://www.example.com:8080/pagename.html

    The question mark following the page name in a URL starts a list of parameters being passed from the browser to the script running in the server. The parameter values can be more or less anything; by convention spaces will have been replaced by plus signs, but otherwise almost anything goes, including colons. For example,

    http://www.example.com/filename.pl?credentials=myuserid:zomg_dont_send_passwords_in_the_clear