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.

Sorting a police blotter 154Sloppy copy-and-pasteVisit one <strong>of</strong> the pages at the Colorado Springs online police blotter²⁸. Each page should have 10reports.If you copy-and-paste the entire webpage into a textfile, though, you get a mess like this (the nameshave been changed from the actual report but the (amazing) events are verbatim):17836 Record ID March 5, 2013 Incident Date 6:59:00 AM Time Sand Creek – ShiftIDivision OtherTitle190X Carmel DriveLocationSand Creek Officers were sent to theWestwind Apartments. <strong>The</strong> reporting party said her boyfriend was cut with a sword bya neighbor. Medical personnel staged and <strong>of</strong>ficers responded to the scene. Investigationrevealed that Sean Doe went to Guy Incognito’s apartment with a Samurai sword. Doeswung the sword at Incognito’s face when Incognito opened his door. Incognito caughtthe blade in both hands and he was able wrestle the sword away. Incognito and Doewere bleeding extensively. Officers arrested Doe at his apartment. Incognito and Doewere transported to Memorial Central for treatment. Both are in stable condition andawaiting surgery.SummarySean DoeAdults Arrested Lt. Strassburg-Aldal - 444-7270PDContact & NumberWhat happened? It’s a consequence <strong>of</strong> how the HTML is structured, a topic that we don’t need toconcern ourselves with. All that matters is we have a jumble.But luckily, the jumble isn’t too bad. <strong>The</strong> problem is that the data labels, such as “Record ID” and“Adults Arrested” have been thrown into the text with no separation. However, as long as thosedata labels stay the same for each record, then we can use them to create a usable regex.Below is the jumbled text again, except that I’ve bolded the data labels:17836 Record ID March 5, 2013 Incident Date 6:59:00 AM Time Sand Creek – ShiftIDivision OtherTitle1900 Block <strong>of</strong> Carmel DriveLocationSand Creek Officers weresent to the Westwind Apartments. <strong>The</strong> reporting party said her boyfriend was cutwith a sword by a neighbor. Medical personnel staged and <strong>of</strong>ficers responded to thescene. Investigation revealed that Sean Doe went to Guy Incognito’s apartment with aSamurai sword. Doe swung the sword at Incognito’s face when Incognito opened hisdoor. Incognito caught the blade in both hands and he was able wrestle the swordaway. Incognito and Doe were bleeding extensively. Officers arrested Doe at hisapartment. Incognito and Doe were transported to Memorial Central for treatment.Both are in stable condition and awaiting surgery.SummarySean DoeAdults ArrestedLt. Strassburg-Aldal - 444-7270PD Contact **& NumberIt appears the data labels come after their associated data, e.g:Time Sand Creek – Shift IDivision²⁸http://www.springsgov.com/units/police/policeblotter.asp

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

Saved successfully!

Ooh no, something went wrong!