13.07.2015 Views

Download - The Bastards Book of Regular Expressions

Download - The Bastards Book of Regular Expressions

Download - The Bastards Book of Regular Expressions

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Matching any letter, any number 651200 block <strong>of</strong> Houston St.400 block <strong>of</strong> W. Abbey Ave.00 block <strong>of</strong> S. 8th StreetAnswerWe basically want to “zero out” the least significant digits <strong>of</strong> an address. On a street where theaddress numbers are three or four digits, zeroing out the last two digits generally provides enoughvagueness.We can use \d to match any numerical digit and curly braces to target 1 to 2 digits. We also needto use a right-side word boundary so that the rightmost digits are matched:Find \d{1,2}\bReplace 00 block <strong>of</strong>Note: <strong>The</strong>re are competing public interests to consider here: we want to mask the exact address <strong>of</strong>the incident. However, we also don’t want to redact the address to the point that its geographicalcharacteristic is rendered meaningless or paints a misleading characteristic.For instance, if we changed the range <strong>of</strong> the curly braces like so:Find \d{1,3}Replace 000 block <strong>of</strong><strong>The</strong>n the following addresses:1520 Broadway, New York, NY1001 Broadway, New York, NY1999 Broadway, New York, NYAre effectively mapped to:1000 block <strong>of</strong> Broadway, New York, NY1000 block <strong>of</strong> Broadway, New York, NY1000 block <strong>of</strong> Broadway, New York, NYIn New York, TK map image

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!