Skip to Content
Mastering Regular Expressions, 3rd Edition
book

Mastering Regular Expressions, 3rd Edition

by Jeffrey E.F. Friedl
August 2006
Intermediate to advanced
542 pages
15h 33m
English
O'Reilly Media, Inc.
Content preview from Mastering Regular Expressions, 3rd Edition

1Introduction to Regular Expressions

Here’s the scenario: you’re given the job of checking the pages on a web server for doubled words (such as “this this”), a common problem with documents subject to heavy editing. Your job is to create a solution that will:

  • Accept any number of files to check, report each line of each file that has doubled words, highlight (using standard ANSI escape sequences) each doubled word, and ensure that the source filename appears with each line in the report.
  • Work across lines, even finding situations where a word at the end of one line is repeated at the beginning of the next.
  • Find doubled words despite capitalization differences, such as with ‘The the...’, as well as allow differing amounts of whitespace (spaces, tabs, new-lines, and the like) to lie between the words.
  • Find doubled words even when separated by HTML tags. HTML tags are for marking up text on World Wide Web pages, for example, to make a word bold: ‘...it is <B>very</B> very important...’.

That’s certainly a tall order! But, it’s a real problem that needs to be solved. At one point while working on the manuscript for this book, I ran such a tool on what I’d written so far and was surprised at the way numerous doubled words had crept in. There are many programming languages one could use to solve the problem, but one with regular expression support can make the job substantially easier.

Regular expressions are the key to powerful, flexible, and efficient text processing. Regular expressions ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ultimate Go Programming, Second Edition

Ultimate Go Programming, Second Edition

William Kennedy

Publisher Resources

ISBN: 0596528124Errata Page