use strict;
my $str = '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';
my $regex = qr/https?:\/\/(?:[^\/]+\/){4}(.*)/p;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
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 Perl, please visit: http://perldoc.perl.org/perlre.html