I have a simple regex ^\\{2}[a-z0-9?_?]*\\{1}[a-z0-9?_?]*$ that can validate folder paths of the type \\foo_bar1\foo_bar_2.
The problem is that the complete path is created by the user using a form and it is unknown how deep the user might want to nest directories. Regardless, I want to make sure that the path is validated, for example, the user might want to create a path like \\foo_bar1\foo_bar_2\foo_bar_3\foo_bar_4\foo_bar_n.
Is there a way I can generalize the \\{1}[a-z0-9?_?]* part of the regex for the above problem for n number of nested directories?
?_?? Looking at your example I guess^\\\\\w+(?:\\\w+)*$will work.?_?numbers and underscores can be optional in the folder path, however no other special characters\wis shorthand for[A-Za-z0-9_].?:doing though? also, if you feel like it, could you please write a short answer and I can accept it :) thanks