$string = "hello/welcome";
i want "welcome" only.
$string = "hello-welcome-to-the-world";
i want "hello-welcome"
i try this
print $1 if($string =~ m#(?:/|)(.*)(?:-to-)#); # got hello-welcome
print $1 if($string =~ m#(?:/)(.*)(?:-to-|)#); # got welcome
but i cant able to get the required output from single regexp . please solve and explain ...
by using this (?:\w.+/)?(.*?(?=$|-to-))
, i got the answer for both strings