http://www.perlmonks.org?node_id=357389

Anneq has asked for the wisdom of the Perl Monks concerning the following question:

I came across the following paragraph in perlretut regarding negation of character classes:
"Because a period is a metacharacter, it needs to be escaped to match as an ordinary period. Because, for example, \d and \w are sets of characters, it is incorrect to think of [^\d\w] as [\D\W]; in fact [^\d\w] is the same as [^\w], which is the same as [\W]. Think DeMorgan's laws."

My question is, why is it incorrect to think of [^\d\w] as [\D\W]?

UPDATE

While gjb and scooterm explained it clearly, (I realized after the fact), I still didn't get it, duh! Zaxo's explanation turned on the light bulb. Thanks to all. Next stop, google for DeMorgan's laws. Thank's to BrowserUK for giving me something to play with.

Anne