sybaritefury (1) [Avatar] Offline
#1
One grammatical, one perl:

On page 115, the "Van" that is quoted has two LH quotes. I've seen Word do that to me before smilie

My Perl question has to do with the part that says "To handle decimal places as well, such as 3.14, the sequence [d.]+ could be used instead."

I think that would match 3.1. but not 3.14 ?
Wouldn't that need to be something like d+.*d* ....or am I misreading that expression?

When I started I thought this book would be too beginner for me, but I have learned quite a few things-- thanks!! I really appreciate that it's not a dull, boring textbook, too. Read too many of those in college, wish we had read books like this instead. smilie
tmaher (37) [Avatar] Offline
#2
Re: Page 115/ section 4.9.1
> One grammatical, one perl:
>
> On page 115, the "Van" that is quoted has two LH
> quotes. I've seen Word do that to me before smilie

Oops!

> My Perl question has to do with the part that says
> "To handle decimal places as well, such as 3.14, the
> sequence [d.]+ could be used instead."
>
> I think that would match 3.1. but not 3.14 ?

The square brackets define a "character class", which is
the list of acceptable characters. The + requires one or
more of the listed characters, so that pattern would indeed
match 3.14, as well as .00042, 97.49, and so forth.

> Wouldn't that need to be something like d+.*d*
> ....or am I misreading that expression?

You're thinking of the contents of the character class as
a series of specifications, rather than an enumeration of
the acceptable characters--in any sequence!

However, you could write a pattern that would match
numbers with (or without) decimals, which would look
something like this:

d*.?d*

That says there can be zero or more digits, optionally (?)
followed by a period, followed by zero or more digits.
But this pattern isn't perfect--for example, it would
match a period that lacks any prior or following digits!
The character-class version has the same limitation
(along with additional ones). I showed the character-
class version at that point in the book because of its simplicity.

> When I started I thought this book would be too
> beginner for me, but I have learned quite a few
> things-- thanks!! I really appreciate that it's not a
> dull, boring textbook, too. Read too many of those
> in college, wish we had read books like this instead.
> smilie

Glad to hear you like it! Feel free to spread the word 8-}