in reply to Search and Extract from String
" ...
#Split the remaining string by space.
#check if last word is "-". If it is, extract the second last word,which will be "design"."
Test case:
perl -E "my $s = 'This is a design-controlled'; my @arr=split / /, $s; for $_(@arr) { say $_;}"Output (note that last word is NOT a stand-alone hyphen/dash):
This is a design-controlled
And the "second last word" is "a"
|
|---|