import re HKEY_LOCAL_MACHINE SYSTEM CurrentControlSet Services TrkWks

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
>>> import re
>>> s = """HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TrkWks
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TSDDD
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tssdis
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Udfs
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ULM
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ultra"""
>>> re.findall(r'\\([^\\]+?)(?:\Z|\n)', s)
['TrkWks', 'TSDDD', 'Tssdis', 'Udfs', 'ULM', 'ultra']
>>>