The goal is to output the name of devices mounted in the cluster like '\dev\spdk\nvme1n1', '\dev\spdk\nvme222n101', etc.
The first regex pattern can fulfill the requirements, but it also returns false positives like '\dev\spdk\nvme1xn1z', '\dev\spdk\nvme2xn1'. And I want to avoid the same.
The second regex is not working as expected because glob doesn't support '+' in regex searching for file/dir names?
>>> import glob
>>>
>>> device = glob.glob(r'/dev/spdk/nvme*n*')
>>> print(device)
['/dev/spdk/nvme2n1', '/dev/spdk/nvme1n1', '/dev/spdk/nvme0n1']
>>>
>>> device2 = glob.glob(r"/dev/spdk/nvme\d+n\d+")
>>> print(device2)
[]
Till date, the only solution I come up with is,
glob.glob(r'/dev/spdk/nvme[0-9]*n[0-9]*')
, but it is again capable of returning false positives like '\dev\spdk\nvme1xn1z' or '\dev\spdk\nvme11n22z'.
Is it even possible to achieve the result without having any false positives? I need a solution using regex + glob only.