marijnh / Eloquent-JavaScript

The sources for the Eloquent JavaScript book
https://eloquentjavascript.net
3.01k stars 796 forks source link

Chapter 9, exercise 3 hint revision #322

Closed dhollinden closed 6 years ago

dhollinden commented 6 years ago

In the hint for ch. 9 exercise 3, the hint states:

"Matching the optional sign in front of the number, as well as in front of the exponent, can be done with [+-]? or (+|-|) (plus, minus, or nothing)."

It seems to me that "[+-]?" should be "[+-]?"

Hope I'm not incorrect. Thanks.

marijnh commented 6 years ago

The minus is escaped because it has a special meaning in character sets—[a-z] matches any character from 'a' to 'z'. In this case, since there is no character after the minus, it would also work without escaping, but it's a good idea to always escape minus characters inside of sets.