in reply to Retrieve second occurrence and everything afterwards using regex

Forget complicated regex. For this you can use rindex / substr:
use strict; use warnings; my $regex = '\default\main\TSDEMO\WORKAREA\tsdemo_intranet\TSDEMO\imag +es\corner'; my $website = 'TSDEMO'; my $parent = substr($regex, rindex($regex, $website)); print $parent;
(note that this gives TSDEMO\images\corner with no leading \, since you don't have $website as \TSDEMO)

Or if you really MUST have case insensitive matching - which doesn't make sense because file paths are sensitive - you can make uppercase copies of the original string and use those:

use strict; use warnings; my $regex = '\default\main\TSDEMO\WORKAREA\tsdemo_intranet\TSDEMO\imag +es\corner'; my $website = 'TSDEMO'; my $tregex = uc($regex); my $parent = substr($regex, rindex(uc($regex), uc($website))); print $parent;
BTW, what you're asking for is the third match, not the second. With case insensitive matching, tsdemo from tsdemo_intranet also matches.