Regexp groups not properly supported #22

bmcorser opened this Issue Jul 5, 2013 · 3 comments


None yet

2 participants

bmcorser commented Jul 5, 2013

I can't use regexps such as (?P<var_name>\d+(,d+)*)/ in my URLconfs, because the nested parens mess up the regexp used by Django.js to match kwargy URLconfs.

The solution looks a bit tricky, might be something more than just a regexp to figure out what is happening in the rexexp for the URLconf.

A cursory Google yielded don't know if this package is useful.


I must admin Django.js was design to handle simple Regexes.

The main problem is that JavaScript native regex support is really poor.
The consequence, I can't simply serialize regexps to handle them client side.

I was thinking in using something like XRegExp but I choose not to introduce javascript dependencies, except for jQuery, which is commonly used.

I will see what I can do to fix that.


About pyparsing, I don't want to introduce such a dependency.
It will produce a too big server-side perfomance overhead.
This is why I prefer to look into simplfying serialization to handle regexp client side with a real regex parser.


I pushed a little workaround for your case.
If you write your regex like this (?P<var_name>\d+(?:,\d+)*)/ it will work.

I already remove non-capturing optionnal groups and characters.
With this push, I treat non-capturing starred groups and starred characters as optionnals (and they are, so I improved the algorithm in fact).
In your regex, I just made the inside group non-capturing to be treated like that by Django.js serialization.
It will still match the same URLs but it's serializable now.

I don't know if my explanation is understandable, but try it and let me know if it works for your case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment