<p>I could use some help writing a regular expression.  In my Django application, users can hit the following URL:</p>

<pre><code>http://www.example.com/A1/B2/C3
</code></pre>

<p>I'd like to create a regular expression that allows accepts any of the following as a valid URL:</p>

<pre><code>http://www.example.com/A1  
http://www.example.com/A1/B2  
http://www.example.com/A1/B2/C3  
</code></pre>

<p>I'm guessing I need to use the "OR" conditional, but I'm having trouble getting my regex to validate.  Any thoughts?</p>

<p><strong>UPDATE</strong>: Here is the regex so far.  Note that I have not included the "<a href="http://www.example.com" rel="nofollow noreferrer">http://www.example.com</a>" portion -- Django handles that for me.  I'm just concerned with validating 1,2, or 3 subdirectories.</p>

<pre><code>^(\w{1,20})|((\w{1,20})/(\w{1,20}))|((\w{1,20})/(\w{1,20})/(\w{1,20}))$
</code></pre>

```
```
http://www\.example\.com/A1(/B2(/C3)?)?
```
```