9
Reply

RegEx to get only page name from URL

Tony Serva

Tony Serva

Sep 23 2008 1:27 PM
12.6k
Hi, Can anyone help me to understand how to take:,
http://www.mywebsite.com/news/local_news/Bullet-riddled_body_found_on_North_Side.html
And strip off everything before the last "/"
to result in:
Bullet-riddled_body_found_on_North_Side.html
The replace on the ".html" is something I know how to do and I think i need to use:

Regex RE = new
Regex("/",RegexOptions.RightToLeft);
Match theMatch = RE.Match(URL);

But his only returns the character "/".
How do you say delete everything before the first instance of the "/" character looking left to Right?

Thanks in advance.

Answers (9)