![]() |
Chapter 1 - Regular Expressions - Capturing Data
Not sure how to suggest an errata .... or indeed to be proved wrong :)
Page 53, Capturing data, example:- /('|")[^\1]*?\1/ The notes indicate that the ? is important because you need to make the match lazy so that it matches the first instance and not a "giant quoted string" made up of multiple quoted strings - this seems to me to be wrong. If you look at the example without the question mark... /('|")[^\1]*\1/ ... you will see that this will NEVER match multiple quoted strings on the same line because the section between the quotes has to match the pattern [^\1]* (i.e any character EXCEPT a quote) - The "giant quoted string" option is therefore not possible because it would have to contain a quote, which clearly it cannot. Does that make sense? I am not big on complaining about such things, but since pattern matching is so often misunderstood I felt that this early reference to it in the book needed to be correct. Here's hoping I got this wrong :) Moopi |
| All times are GMT -4. The time now is 01:52 PM. |
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.