in reply to Retrieve second occurrence and everything afterwards using regex

Hi,
You could use a positive lookahead like this:
use strict; use warnings; my $regex = "\\default\\main\\TSDEMO\\WORKAREA\\tsdemo_intranet\\TSDE +MO\\images\\corner"; my $website = "TSDEMO"; $regex =~ m/($website.*)(?=\\$website)/gi; my $parent = $'; print "$parent\n";
But what is wrong with concatenating the $website variable to the result?
BTW your (and my) code does not find the second but the last occurance of $website.
si_lence
  • Comment on Re: Retrieve second occurrence and everything afterwards using regex
  • Download Code