Police-Data-Accessibility-Project / scrapers

Code relating to scraping public police data.
https://pdap.io
GNU General Public License v3.0
157 stars 35 forks source link

Fix parsing when charge statute contains a nested bracket. #18

Closed OscarVanL closed 4 years ago

OscarVanL commented 4 years ago

This would previously incorrectly parse FAIL TO DISPLAY REGISTRATION - POSSESSION REQUIRED (320.0605(1)) as:

charge == FAIL TO DISPLAY REGISTRATION - POSSESSION REQUIRED (320.0605

statute == 1

Now it correctly parses as:

charge == FAIL TO DISPLAY REGISTRATION - POSSESSION REQUIRED

statute == 320.0605(1)

Due to the nature of these nested brackets, recursive regex is used. This requires the use of the regex library, as the python re library does not support recursive regex.