$s =~ /(^(?:[^_]+_){3})/ and print "'$1'";; 'fred_bill_john_'