#!/usr/bin/perl use strict; use warnings; my $row = 'We_need_feed'; #my ($last) = $row =~ /[^_]$/g; #match we #my ($last) = $row =~ /^\w?[^_]/g;#match feed my ($last) = $row =~ /[need]+$/g ; print "$last\n";