if( $string =~ m/ \b([[:alpha:]]+)\b # Match and capture word .*? # Skip what you don't need \b\1\b # Match the captured word /x ) { print $1, "\n"; }