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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Matching any letter, any number 73Exercise: Cleaning up Wikipedia notationsEvery once in awhile when doing research, you find yourself on a Wikipedia webpage, and thecontent is so great that you want to insert it directly into your own paper. And hey, that’s fine,because Wikipedia information is free!But here’s the first problem you run into: the best Wikipedia content is <strong>of</strong>tentimes the most wellannotatedcontent. Which means when you copy-and-paste, you’re getting that great text plus allthose bracketed numbers, which is not what your own research paper needs:Giant Panda entry from WikipediaHere’s the text you get when copying-and-pasting from the first paragraph <strong>of</strong> the Giant Panda²⁰entry:<strong>The</strong> panda (Ailuropoda melanoleuca, lit. “black and white cat-foot”),[2] also knownas the giant panda to distinguish it from the unrelated red panda, is a bear[3] nativeto central-western and south western China.[4] It is easily recognized by the large,distinctive black patches around its eyes, over the ears, and across its round body.Though it belongs to the order Carnivora, the panda’s diet is 99% bamboo.[5] Pandasin the wild will occasionally eat other grasses, wild tubers, or even meat in the form <strong>of</strong>birds, rodents or carrion. In captivity, they may receive honey, eggs, fish, yams, shrubleaves, oranges, or bananas along with specially prepared food.[6][7]Write the regex needed to remove these bracketed numbers.²⁰http://en.wikipedia.org/wiki/Giant_panda

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

Saved successfully!

Ooh no, something went wrong!