perl -nle "my (@c) = s/\:(\w+)\:/X/g; print join '.', @c" input> out:caputure1:out:capture2:out output> 2