s/abc\w+\s+\w+(?:, *\w+)\s+//; # match and remove unwanted initial content #### s/.*\s(\w+\s+\w+)$/$1/; # match desired end content and remove everything before it #### $_ = substr( $_, rindex( $_, 'yuio jklh' ));