views:

17

answers:

1

In Django URL patterns, what's the proper way to take this URL:

http://example/i/fb/#access_token=12345678910|b1827b912847b81938747b91849-193867192305817|EKWOGJhcinWIjWij8174-NgjRojb&expires_in=0

And create variables:

access_token = 12345678910|b1827b912847b81938747b91849-193867192305817|EKWOGJhcinWIjWij8174-NgjRojb

expires_in = 0

I've been trying to get this to work, but to no avail...

url(r'^fb/(?P([^&]+)(?:&expires=(.*))?/?$, 'app.views.test_url', name="test_url"),

+1  A: 

Try this:

'[#?&]?([a-z_]+)=([0-9A-Za-z|\-]+)'

Example application in PHP:

<?php

    $url = "http://example/i/fb/#access_token=12345678910|b1827b912847b81938747b91849-193867192305817|EKWOGJhcinWIjWij8174-NgjRojb&amp;expires_in=0";
    preg_match_all("%[#?&]?([a-z_]+)=([0-9A-Za-z|\-]+)%", $url, $matches, PREG_SET_ORDER);

    print_r($matches);

?>
Ruel
Joe
Definitely seems like it should work, but I can't get it to pass the values through. Maybe there's a difference specific to Django. Thanks again, though.
Joe
It looks as the Django will always ignore anchors (don't know if this is Django-specific). Marking this answered as I don't think there's a solution for the methodology I proposed.
Joe