p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   BOOK: Expert PHP and MySQL (http://p2p.wrox.com/book-expert-php-mysql-559/)
-   -   Chapter 1 - Regular Expressions - Capturing Data (http://p2p.wrox.com/book-expert-php-mysql/82777-chapter-1-regular-expressions-capturing-data.html)

moopy February 28th, 2011 04:44 AM

Chapter 1 - Regular Expressions - Capturing Data
Not sure how to suggest an errata .... or indeed to be proved wrong :)

Page 53, Capturing data, example:-


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...


... 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 :)


All times are GMT -4. The time now is 03:39 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.