I'm attempting to parse /etc/mtab but exclude /boot. I thought perhaps non-capturing groups would be the way to go, but it doesn't work as I expected. This is the regex I constructed:
proc = subprocess.Popen(["ssh", server, "cat", mtab],stdout = subprocess.PIPE)
for line in proc.stdout:
fsMatch = re.search(r'([\w/:]+) (/([\w/:-]+)|(?:boot)) (nfs|ext3)', line)
if fsMatch:
print fsMatch.group(1,2,4)
Output:
('/dev/sda1', '/boot', 'ext3')
('/dev/mapper/foo1', '/export/foo1', 'ext3')
('/dev/mapper/foo2', '/export/foo2', 'ext3')
('/dev/mapper/foo3', '/export/foo3', 'ext3')
('/dev/mapper/foo4', '/export/foo4', 'ext3')
('/dev/mapper/foo5', '/export/foo5', 'ext3')
('servernfs:/install', '/mnt', 'nfs')
I'm pretty confident the | is wrong (and obviously more is wrong) but have hit a roadblock.
I'm looking for all matches for /[\w/:-]+ but exclude matches to /boot
Suggestions?