my $string = "Hallo\nWelt!"; print "[$1][$2]\n" if $string =~ m/(...)^(...)/ms;