$test[$z] =~ /^\[ ([^\]]+) # Datum \] \s+ \[ ([^\]]+) # Fehler \] \s+ (?>\[\S+\s([^\]]+)\]\s+)? # falls [client ...] Lookahead (.+) $ /x;