Feb-04-2022, 08:23 AM
Thank you for the code!
Do you think you could elaborate on why your snipped is working and my is not?
even if I add your regex it is not printing anything...
it seems exactly the same.
your code:
Do you think you could elaborate on why your snipped is working and my is not?
even if I add your regex it is not printing anything...
it seems exactly the same.
your code:
tofind = r'^[A-Z0-9]{8}_\d{4}$' for d in ["_Y151029E_7345", "D151009EN_7295", "mydir","small_11","TST___3456","TST_3456","TST3456"]: if re.findall(tofind,d): print(f"{d} Matched") else: print(f"{d} no match")And I wrote (the directories names are the same):
import re from pathlib import Path tofind = r'^[A-Z0-9]{8}_\d{4}$' for ed in Path('C:\\01\\TLogs').iterdir() : if ed.is_dir(): rudir = Path(ed).parts[3] print(f" Dir_Name -{rudir}") if re.findall(tofind,rudir) : print(f" found -> {rudir}")