using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"https?:\/\/(?:[^\/]+\/){4}(.*)";
string input = @"https://firstURL/Second/Third/Fourth/five/SearchResults?json=%7B%22SalesInventoryID%22%3Anull%2C%22BundleInventoryID%22%3Anull%2C%22InventorySalesPriceID%22%3Anull%2C%22SiteType%22%3A8%2C%22SiteName%22%3A%22Desert%20Club%22%2C%22PointsMin%22%3A1%2C%22PointsMax%22%3A999999%2C%22RoomType%22%3Anull%2C%22PriceMin%22%3A1%2C%22PriceMax%22%3A999999%2C%22SeasonType%22%3Anull%2C%22FrequencyType%22%3Anull%2C%22CheckInType%22%3Anull%2C%22WeekMin%22%3A1%2C%22WeekMax%22%3A52%2C%22RoomMin%22%3A%221%22%2C%22RoomMax%22%3A%22999999%22%2C%22TourID%22%3A2022154%2C%22TourLocationID%22%3A54%2C%22ListResults%22%3Anull%2C%22BundledResults%22%3Anull%2C%22TourParticipantInfo%22%3A%7B%22TourID%22%3A2022154%2C%22SiteID%22%3A1%2C%22SiteName%22%3Anull%2C%22PersonID%22%3A364182%2C%22FirstName%22%3A%22Lynn%20A.%22%2C%22LastName%22%3A%22McDougald%22%2C%22City%22%3A%22Charlotte%22%2C%22State%22%3A%22-%22%2C%22ShortState%22%3A%22-%22%2C%22Country%22%3Anull%2C%22CountryID%22%3A840%2C%22OwnerNumber%22%3A%226017104%22%2C%22OwnerStatus%22%3Anull%2C";
foreach (Match m in Regex.Matches(input, pattern))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx