On Debian Stretch the cmdline is something like:
qemu-system-x86_64-enable-kvm-nameguest=vmname,debug-threads=on-S-[…]
Without null characters:
qemu-system-x86_64 -enable-kvm -name guest=vmname,debug-threads=on[…]
We need to match only guest=vmname, so the regex
"^.*guest=([a-zA-Z0-9.-_-]*).*$" is simpler and match the VM name.
The precedent regex "^.*-name\x00([a-zA-Z0-9.-_-]*)\x00\-.*$" was not matching it.
BTW, It seems that \x00 does not match correctly null characters so I removed it.