#!/usr/bin/perl use strict; use warnings; my $case1 = "Club: Some Club Comments: "; my $case2 = "Club: Comments: "; foreach my $text ($case1, $case2) { # extract Club name (my $club) = $text =~ /Club:(.*)/; # need to allow for blank Club name $club =~ s/^\s*//; $club =~ s/\s*$//; print "line before name\n"; # print out to make sure $club doesn't have a \n print "extracted Club name: '$club'\n"; print "line after name\n"; } __END__ line before name extracted Club name: 'Some Club' line after name line before name extracted Club name: '' line after name ======== I've tried things like: /Club:\s*(.*)[ ]*\n/ and various other encantations, but that picks up 'Comments:' intead of a blank Club name line before name extracted Club name: 'Some Club' line after name line before name extracted Club name: 'Comments:' line after name