django-councilmatic icon indicating copy to clipboard operation
django-councilmatic copied to clipboard

Generalize district table filter regex

Open patcon opened this issue 8 years ago • 0 comments

Related to this line: https://github.com/datamade/django-councilmatic/blob/master/councilmatic_core/templates/partials/map.html#L140

Couple things that lead to unexpected behaviour:

  • If a ward is named something like "Trinity-Spadina (19)", then the parentheses must be escaped with a helper like this
  • The \b metacharacter doesn't match correctly if a district name starts or ends with a parenthesis. Wasn't getting a match until I removed the \\b at the end.

This is very unexpected behaviour, and not inconcievable that someone else could hit it and spend quite a bit of time sorting it out. May I submit a PR to:

  1. Remove the "\b" metacharacters.
  2. Add a utility function to escape the regex.

cc: @jpmckinney, since you'll likely hit the same thing with other Canadian divisions

cc: @derekeder, since git-blame says you have the context :)

patcon avatar Apr 08 '16 22:04 patcon