in reply to Regex Optimization Question

This seems to do basically what you want. I just extract what's between quotes and join them together with a backslash. Updated to handle "Account Deleted".
use strict; use warnings; my $string = q/ Win32_Account.Domain="ADDomain",Name="aduser1"/; for my $string (q/ Win32_Account.Domain="ADDomain",Name="aduser1"/, q/ Win32_Account.Domain="ADDomain",Name=""/) { my @fields = $string =~ /"(.*?)"/g; printf "New string is (%s)\n", $fields[1] eq '' ? 'Account deleted' +: join '\\', @fields; }

Caution: Contents may have been coded under pressure.