#!/usr/bin/perl -w use strict; my $test = "ASDFE:asdfe"; $test =~ s! # Substitute (?<= # Zero-width positive lookbehind [A-Z]{5} # Five caps ) # end lookbehind : # Substituting a colon (but not the preceeding characters) !:\n

!x; print $test;