Python- Regex for dir of certain depth -
I have a regex expression but it is not working for all cases.
I need this to match any low level case to two levels of depth:
If this word is in the "test_word" statement then it is true.
What I am using is not working
('^ / [^ /] * / test_word..+') or
('^ / so I'm matching in statements with dirs like: / user / test_word / test_word / test_word / Test_word / But this example is wrong because it's beyond two levels. Do not want to be positive for anything beyond
/ some / some / test_word / and whatever you think can happen / P>
I think you want something like that,
^ (?. *? / Test_word) (?!! *? //) \ / (?: [^ /] *) (?: / [^ /] *)? /? $
Comments
Post a Comment