I have a parent folder Z:\data\ containing subfolders as follows:
Z:\data\8346835623\
Z:\data\8346835623\
...
Z:\data\clicks\
Z:\data\useless\
...
What regex expression should I use to get the folders that are named as integers?
>Solution :
You can use the character class \d to specify ‘a digit (0-9)’ followed by the quantifier {10} to specify ‘exactly 10 of…’
Assuming everything is in Z:\data\, this pattern should match the files you want
Z:\\data\\\d{10}\\
The additional backslashes are used to escape the literal backslash characters in the path.
Here’s the verbatim explanation from https://regex101.com
Z: matches the characters Z: literally (case sensitive)
\ matches the character \ with index 9210 (5C16 or 1348) literally (case sensitive)
data matches the characters data literally (case sensitive)
\ matches the character \ with index 9210 (5C16 or 1348) literally (case sensitive)
\d matches a digit (equivalent to [0-9])
{10} matches the previous token exactly 10 times
\ matches the character \ with index 9210 (5C16 or 1348) literally (case sensitive)