RegEx Pattern - Determining the name of the page

[.+]?/(?<pagename>[^/]+).aspx

If the only thing necessary is to determine the name of the page (without path information) this regex pattern did the job for me.

Published Tuesday, November 30, 2004 7:43 PM by Palermo4
Filed under: ,

Comments

# re: RegEx Pattern - Determining the name of the page

Tuesday, November 30, 2004 11:07 PM by Scott
I think it was Obi-Wan who said, “Use the framework Mike”. :)

You might want to check out System.IO.Path:

Path.GetFileName(string path)
and
Path.GetFileNameWithoutExtension(string path)

-Scott

# re: RegEx Pattern - Determining the name of the page

Thursday, December 02, 2004 2:00 AM by Michael Palermo
[face turning a shade of red]

I thought System.IO.Path did a file validation check. So I tested this against a vanity path - and you are absolutely correct. Perhaps I can save face by saying I meant to use RegEx? Yeah, I don't buy that story either.

Thanks. You are a Jedi Master.

# re: RegEx Pattern - Determining the name of the page

Monday, December 13, 2004 11:49 AM by Tony Vervilos
This is a great site for regular expressions

http://sourceforge.net/projects/regulator/

# re: RegEx Pattern - Determining the name of the page

Sunday, November 18, 2007 1:11 PM by Tanveer Badar

Stick a (.*)? to the end of it for allowing query string.

Leave a Comment

(required) 
(required) 
(optional)
(required)