Errata

Mastering Regular Expressions

Errata for Mastering Regular Expressions, Third Edition

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
PDF
Page xviii
2nd paragraph

"Yet, the *first* edition gradually started to show its age. ... It was published in 2002, ..." This paragraph describes the second edition.

Note from the Author or Editor:
Change "It was published in 2002" to "The second edition was published in 2002"

Jon W.  May 06, 2010  Apr 10, 2015
Mobi
Page 9
1st para

"Ther egular-expression construct" should be "The regular-expression construct"

Anonymous  Sep 23, 2013  Mar 10, 2014
Printed
Page 13
3rd paragraph, and British spellings example

3rd paragraphh (change f to F): (first|1st) and (fir|1)st should be (First|1st) and (Fir|1)st

Remove the space in this example: (Geoff|Jeff) (rey|ery)

Note from the Author or Editor:
The last line of paragraph three, which begins "understand that...", capitolize the 'f' after the open paren of each regex:
understand that (First|1st) and (Fir|1)st effectively mean the same thing.

The comment about the space is not appropriate, since there is no extra space there. Perhaps there appears to be one, and so I suppose the )( could be kerned a bit closer, but not a big deal.

Anonymous  Dec 09, 2009  Mar 14, 2014
Printed
Page 49
item 1 in list

ambiguous grammar:

Most tools have their own particular flavor of regular expressions. Perl's appear to be of the same general type as egrep's, but has a richer set of metacharacters.

one option:
"Perl's [regular expressions] appear..., but [Perl] has..."

another (more concise) option:
Perl's flavor is similar to egrep's, but Perl has a richer set of metacharacters.

Note from the Author or Editor:
I don't think it's ambiguous, but it doesn't hurt to clarify. Also, "appear" should be "appears".

Anonymous  Feb 07, 2010  Apr 10, 2015
Printed
Page 51
1st and 6th paragraphs

Missing comma after introductory interjection "Yes". The sentence should read, "Yes, Tom Cruise, I bet you could!" The statement of the name "Tom Cruise" is in apposition to the rest of the sentence. This error occurs in the planning of the demonstration sentence and in the code that generates it.

John O'Keefe-Odom  Oct 24, 2013  May 20, 2016
Printed
Page 63
Table 2-1 row 3 comment

Printed: "... but this not of much practical value ..."
Fixed: "... but this is not of much practical value ..."

Note from the Author or Editor:
Book is in error.

Jeff Roberson  Mar 03, 2010  Mar 14, 2014
Printed
Page 69
Last line on the page

Printed: "... or perhaps ^[ \t\r]*$ to allow ..."
Fixed: "... or perhaps ^[ \t]*$ to allow ..."
Discussion: The as-printed wording and regex works A-Ok on Unix text files where the \r is considered to be nothing but extraneous whitespace. However, on DOS/Windows text files, you don't really want to go stripping out the \r which is a part of each valid line termination sequence. Running your regex as printed will cause the file to be converted from a valid DOS/Windows text file (with only CR-LF terminations), to a corrupted "mixed" text file (having both LF and CR-LF terminations). But, I think the final solution on page 70 using 's/^\s*$/<p>/mg' will work just fine, because with regex tools designed to work with DOS/Windows text files, the '$' metachar should stop before the CR, and only "whole" line terminations (either CR-LF or LF) will be consumed by the \s+.

Note from the Author or Editor:
Book is in error, and it spills over to three places on page 70.

Jeff Roberson  Mar 03, 2010  Apr 10, 2015
Printed
Page 74
last line

the marker that shows the match for http://www.slashdot.com should extend to include the exclamation mark. This is the purpose of the example I believe

Note from the Author or Editor:
Book is in error.

Anonymous  Feb 12, 2009  Apr 10, 2015
Other Digital Version
81
middle

$price?=~?s/(\.\d\d[1-9]?)d*/$1/

Should be:

$price?=~?s/(\.\d\d[1-9]?)\d*/$1/

That is made clear a little farther down the page.near the bottom of the next paragraph after the code example shown above.

Note from the Author or Editor:
This error does not appear in the print version (it's on page 52 of the print version). Please check digital versions to make sure that they match the print version, taking particular note of that )\d includes the backslash.

stosss  Aug 30, 2011  Mar 14, 2014
Printed, PDF
Page 87
footnote

Double space after "I" in "[...] - ask me, I know!"

Julian R.  Sep 10, 2013  Apr 10, 2015
Printed
Page 94
Second paragraph, last sentence

Printed: "... this style is use by most (non-Perl) languages, ..."
Fixed: "... this style is used by most (non-Perl) languages, ..."

Note from the Author or Editor:
Book is in error.

Jeff Roberson  Mar 03, 2010  Apr 10, 2015
PDF
Page 96
2nd code snippet

if (! line.matches("\\s*", ))
should be
if (! line.matches("\\s*"))

The extra comma results compilation fails.

Note from the Author or Editor:
Book is in error.

Anonymous  Nov 23, 2011  Apr 10, 2015
Printed
Page 199
First "not recommended" regex

Printed: "... s/\s*(.*?)\s*$/$1/s ..."
Fixed: "... s/^\s*(.*?)\s*$/$1/s ..."
Discussion: This is the first of the "not recommended" example regexes listed which strip leading and trailing whitespace. All the other examples have a beginning of string anchor '^', thus, it makes sense that this one should also have it.

Note from the Author or Editor:
Book is in error

Jeff Roberson  Mar 03, 2010  Apr 10, 2015
Printed
Page 210
Second to last paragraph, second sentence

Printed: "... better to use [1235-9] instead of [^4], ..."
Fixed: "... better to use [0-35-9] instead of [^4], ..."
Discussion: Zero is a valid "not four" digit. Although the [1235-9] syntax would be appropriate for the leading digit (if it is not allowed to be a zero). Do zip codes ever lead with a zero?

Note from the Author or Editor:
Book is in error

Jeff Roberson  Mar 03, 2010  Apr 10, 2015
Printed
Page 218
Third paragraph, third sentence

Printed: "... In practice, would I do add this? ..."
Fixed: "... In practice, would I add this? ..."

Note from the Author or Editor:
Book is in error

Jeff Roberson  Mar 03, 2010  Apr 10, 2015
Printed
Page 261
Third paragraph, second sentence

Printed: "... from (?:this|that):) to ..."
Fixed: "... from (?:this|that): to ..."
Discussion: As written, the regex has an extra unbalanced closing parentheses which needs to be removed.

Note from the Author or Editor:
Book is in error.

Jeff Roberson  Mar 03, 2010  Apr 10, 2015
Printed
Page 457
Last sentence on page

Printed: "... but since they retained, you can simply ..."
Fixed: "... but since they are retained, you can simply ..."

Note from the Author or Editor:
Book is in error.

Jeff Roberson  Mar 03, 2010  Mar 14, 2014
Printed
Page 459
Last sentence on page

Printed: "... the variables are note interpolated ..."
Fixed: "... the variables are not interpolated ..."

Note from the Author or Editor:
Book is in error.

Jeff Roberson  Mar 03, 2010  Mar 14, 2014
Printed
Page 467
First regex, on line 6 of the page

Printed: "... preg_split('/\r? \n \r? \n/x', $response, ..."
Fixed: "... preg_split('/\r? \n \r? \n/xS', $response, ..."
Discussion: In the paragraph following this you state: "(The S pattern modifier is used for efficiency -> 478.)". With this phrase, I can only assume that you are referring to the preceding regex which, as printed, does not have (but evidently needs) the "S" modifier.

Note from the Author or Editor:
Book is in error.

Jeff Roberson  Mar 03, 2010  Mar 14, 2014
Printed
Page 473
The if statement comment in middle of page

Printed: "... /* '/' followed by '\' or EOS */ ..."
Fixed: "... /* '\' followed by '/' or EOS */ ..."
Discussion: The comment description does not quite match the logic of the regex. Swapping the '/' and '\' corrects this.

Note from the Author or Editor:
Book is in error.

Jeff Roberson  Mar 03, 2010  Apr 10, 2015
Printed
Page 484
5th line of first regex near top of page

Printed: "... | <\w[^>]*+/> ..."
Fixed: "... | <\w[^>]*/> ..."
Discussion: As written, the regex consumes (and won't give up because of the possessive modifier), everything up to the closing angle bracket, including the slash. But for this match to work correctly, the engine needs to back up one character and match the slash, but it can't. Removing the possessive '+' modifier from the star fixes the problem and allows the regex to backtrack and match the closing '/>' sequence correctly.

Note from the Author or Editor:
The book is indeed in error. The same error appears twice on page 481, and also on page 482. The others (on pp481-482) were added to my errata in 2006, so perhaps have already been fixed.... I have only a first printing at hand, so I don't know.

Jeff Roberson  Mar 03, 2010  Apr 10, 2015