-1

I have a URL, for example: http://www.di.fm/calendar/event/40351

I want to parse this URL with a regular expression, and retrieve the part after domain. In this case :calendar/event/40351

There can also be additional information after a hash: (e.g., calendar/event/40351#event-info)

Ryan Emerle
  • 15,461
  • 8
  • 52
  • 69
Alex
  • 8,908
  • 28
  • 103
  • 157
  • 1
    Is it this specific domain you need to handle, or any arbitrary domain? –  Oct 10 '14 at 15:51
  • arbitrary domain,.. some string for example – Alex Oct 10 '14 at 15:52
  • 1
    This is no simple question, and you would be better off not using a regex. The linked question has some answers, though. –  Oct 10 '14 at 15:54

1 Answers1

8

You don't need Regex:

var uri = new Uri("http://www.di.fm/calendar/event/40351#123");
var result = uri.PathAndQuery + uri.Fragment;
brz
  • 5,926
  • 1
  • 18
  • 18