jeanwelly said:
$mystring = "andgjdkj..dlodjghghdhhdghhd\ndkkdkd\n/usr/local/ddd\n";
^ ^
^ ^
I want to distill "/usr/loca/add"
What is it about that string that indicates that that is what
should be extracted?
Where did the missing "l" go?
What changed "ddd" to "add"?
from the string and assign to a
variable, thanks!
(my $variable = $mystring) =~ s/^(.*?\/)|\n//sg;
or
my $variable = substr $mystring, rindex($mystring, '/usr/'), -1;
or
my $variable = substr $mystring, 35, 14;
or
my($variable) = $mystring =~ /^(\/.*)/m;
or
my($variable) = $mystring =~ m#(/.*)#;
or
my($variable) = grep /\//, split /\n/, $mystring;
or
my $variable = (split /\n/, $mystring)[2];