6

Forgive my title not being more exact...I need a (simple?) Regex (which I'm awful at) to match the following

/Parent/AnySubDirectory/Child/

Parent and Child are always Parent and Child. Any subdirectory could have any name:

/Parent/Sub1/Child/
/Parent/Sub2/Child/

Everything I research is more complicated than necessary.

roadsunknown
  • 3,190
  • 6
  • 30
  • 36
  • In which regex flavor/language are you planning to use this? – Tim Pietzcker Aug 24 '12 at 19:38
  • The Regex pattern is needed (over another type of solution) as the third party module requiring it in DNN (URL Master) only accepts RegEx patterns to exclude/include directories in processing. Other examples were not provided as they did not work. – roadsunknown Aug 24 '12 at 20:26

2 Answers2

12
/Parent/[^/]+/Child/

should work.

[^/]+ means "One or more characters except slashes".

Tim Pietzcker
  • 328,213
  • 58
  • 503
  • 561
0
^/var/www/html/website/(?:[^/]*/)*/?vendor

See https://regex101.com/r/DAf5BW/1

Geoffrey
  • 5,407
  • 10
  • 43
  • 78