while ($text =~ /($pattern)/g) { my $startindex = $-[0]; my $endindex = $+[0]; my $capture = $1; print "$startindex $endindex\n"; ####REQUIRED OR WON'T WORK CORRECTLY! my $vsoChars = $VShape->Characters; $vsoChars->{Begin}=$startindex; $vsoChars->{End}=$endindex; $vsoChars->{Text}=$capture; $vsoChars->SetProperty('CharProps', 1, $color); }