my $Line = "1243 That will efficiently match a nonempty group with matching parentheses two levels deep or less."; if( $Line =~ /^(\d{4}) ([^\.]+?[\.\!\?])$/ ) { print "$1\n$2\n"; #Do something } elseif( #do some other check }