Match all directory names in file path with regular expression

Posted by Jeremy on Stack Overflow See other posts from Stack Overflow or by Jeremy
Published on 2010-06-17T16:12:25Z Indexed on 2010/06/17 16:33 UTC
Read the original article Hit count: 217

Filed under:
|

Can someone give me the regular expression to match something like /this/is/the/path or /this/is/the/path/ and matches like:

$1=this
$2=is
$3=the
$4=path

([^/]+)/ matches one, but I'm not quite sure how to get it to repeat.

FYI: this is for a mod rewrite RewriteRule match.

© Stack Overflow or respective owner

Related posts about regex

Related posts about mod-rewrite