$re = '/^(?P<key>[^#]\S+) ?= ?"(?P<value>.+)"$/m';
$str = '.encoding = "UTF-8"
bios.bootorder = "hdd,cdrom"
checkpoint.vmstate = ""
cleanshutdown = "TRUE"
config.version = "8"
displayname = "generic-ubuntu1804-vmware"
ehci.pcislotnumber = "-1"
ehci.present = "FALSE"
extendedconfigfile = "generic-ubuntu1804-vmware.vmxf"
floppy0.present = "FALSE"
guestos = "ubuntu-64"
guestos.detailed.data = "bitness=\'64\' distroName=\'Ubuntu\' distroVersion=\'18.04\' familyName=\'Linux\' kernelVersion=\'4.15.0-76-generic\' prettyName=\'Ubuntu 18.04.4 LTS\'"
gui.fullscreenatpoweron = "FALSE"
gui.viewmodeatpoweron = "windowed"
hgfs.linkrootshare = "TRUE"
hgfs.maprootshare = "TRUE"
ide0:0.clientdevice = "TRUE"
ide0:0.devicetype = "cdrom-raw"
ide0:0.filename = "auto detect"
ide0:0.present = "TRUE"
isolation.tools.hgfs.disable = "FALSE"
memsize = "2048"
monitor.phys_bits_used = "42"
msg.autoanswer = "true"
numa.autosize.cookie = "20001"
numa.autosize.vcpu.maxpervirtualnode = "2"
numvcpus = "2"
nvme0.present = "FALSE"
nvram = "generic-ubuntu1804-vmware.nvram"
parallel0.autodetect = "FALSE"
parallel0.bidirectional = ""
parallel0.filename = ""
parallel0.present = "FALSE"
parallel0.startconnected = "FALSE"
pcibridge0.pcislotnumber = "17"
pcibridge0.present = "TRUE"
pcibridge4.functions = "8"
pcibridge4.pcislotnumber = "21"
pcibridge4.present = "TRUE"
pcibridge4.virtualdev = "pcieRootPort"
pcibridge5.functions = "8"
pcibridge5.pcislotnumber = "22"
pcibridge5.present = "TRUE"
pcibridge5.virtualdev = "pcieRootPort"
pcibridge6.functions = "8"
pcibridge6.pcislotnumber = "23"
pcibridge6.present = "TRUE"
pcibridge6.virtualdev = "pcieRootPort"
pcibridge7.functions = "8"
pcibridge7.pcislotnumber = "24"
pcibridge7.present = "TRUE"
pcibridge7.virtualdev = "pcieRootPort"
powertype.poweroff = "soft"
powertype.poweron = "soft"
powertype.reset = "soft"
powertype.suspend = "soft"
proxyapps.publishtohost = "FALSE"
remotedisplay.vnc.enabled = "FALSE"
remotedisplay.vnc.ip = "127.0.0.1"
remotedisplay.vnc.port = "5904"
replay.filename = ""
replay.supported = "FALSE"
sata0.present = "FALSE"
scsi0.pcislotnumber = "16"
scsi0.present = "TRUE"
scsi0.virtualdev = "lsilogic"
scsi0:0.filename = "generic-ubuntu1804-vmware.vmdk"
scsi0:0.present = "TRUE"
scsi0:0.redo = ""
serial0.autodetect = "FALSE"
serial0.filename = ""
serial0.filetype = ""
serial0.pipe.endpoint = ""
serial0.present = "FALSE"
serial0.startconnected = "FALSE"
serial0.trynorxloss = ""
serial0.yieldonmsrread = ""
softpoweroff = "FALSE"
sound.autodetect = "TRUE"
sound.filename = "-1"
sound.present = "FALSE"
sound.startconnected = "FALSE"
svga.guestbackedprimaryaware = "TRUE"
svga.vramsize = "134217728"
tools.synctime = "TRUE"
tools.upgrade.policy = "upgradeAtPowerCycle"
toolsinstallmanager.updatecounter = "1"
usb.pcislotnumber = "-1"
usb.present = "FALSE"
uuid.action = "create"
uuid.bios = "56 4d fc 04 54 ab 8e 06-3c c5 a6 4d f9 c8 bc 5a"
uuid.location = "56 4d fc 04 54 ab 8e 06-3c c5 a6 4d f9 c8 bc 5a"
virtualhw.productcompatibility = "hosted"
virtualhw.version = "12"
vmci0.id = "1861462628"
vmci0.pcislotnumber = "35"
vmci0.present = "TRUE"
vmotion.checkpointfbsize = "134217728"
vmotion.checkpointsvgaprimarysize = "134217728"
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php