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 156I used newlines in the replacement pattern just to produce something easier to read. You could’veused tab characters which would allow you to paste the result directly into Excel:A single tab-delimited police report pasted into ExcelAdding a report-ending delimiterIf you try to apply the regex above to the entire page <strong>of</strong> 10 reports, you’ll find that they don’t copyand-pasteso easy into Excel. This is because some <strong>of</strong> the reports contain extra line breaks. Andcopying/pasting line breaks into Excel will create problems:<strong>The</strong> entire tab-delimited reports list with gratuitous line breaks included, pasted into Excel<strong>The</strong>re’s a few hacks we can use to clean this up. I think the easiest approach is to adjust the Replacepattern:Replace \1\t\2\t\3\t\4\t\5\t\6\t\7\t\8\t\9--END--You can use whatever arbitrary string you want there. <strong>The</strong> important thing is to have that stringdenote the end <strong>of</strong> each report. An example result is:17838 March 5, 2013 2:41:00 PM Falcon – Shift II Burglary 3400 block <strong>of</strong> Sinton RdOn 03-05-13, Officers from the Colorado Springs Police Department were dispatchedto Sinton Rd regarding a burglary. Upon arrival they learned approximately 6 camperstyle vehicles/trailers had been broken into from 03-04-13 6pm to 03-05-13 12:00 pm. Ifyou were a victim <strong>of</strong> one <strong>of</strong> these burglaries please contact the Colorado Springs PoliceDepartment at 444-7000. Lt. Buckley - 444-7240–END–

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

Saved successfully!

Ooh no, something went wrong!