IfI don't know that you are using linuxcan specify ranges. On Linux, you can add a bash function such as from here.
A slight modification should work,
terraform-replace () {
sed 's/\x1b\[[0-9;]*m//g' | grep -o '# [^( ]* ' | grep '\.' | sed " s/^# /-replace '/; s/ $/'/; "
}
Then use it like this,
terraform plan | terraform-replace | grep 'azurerm_windows_virtual_machine.vm\[[0-4]\]' | xargs -r terraform apply -auto-approve