[^\^]

T

toylet

Why does it match "^"? Doesn't [^] mean "not a caret"?

the program I used:

while (<>) {
/[^\^]/ && print "not a caret\n";
}

I inputted "^", and the message printed.
 
P

Paul Lalli

Why does it match "^"? Doesn't [^] mean "not a caret"?

the program I used:

while (<>) {
/[^\^]/ && print "not a caret\n";
}

I inputted "^", and the message printed.

You didn't chomp the input. The regular expression matched by matching
the newline character to the pattern "anything that's not a carrot".

Paul Lalli
 
B

Beable van Polasm

toylet said:
Why does it match "^"? Doesn't [^] mean "not a caret"?

the program I used:

while (<>) {
chomp;

/[^\^]/ && print "not a caret\n";

# don't need the backslash
/[^^]/ && print "not a caret\n";
}

I inputted "^", and the message printed.

The newline wasn't a caret.

--
 
M

Matt Garrish

Paul Lalli said:
Why does it match "^"? Doesn't [^] mean "not a caret"?

the program I used:

while (<>) {
/[^\^]/ && print "not a caret\n";
}

I inputted "^", and the message printed.

You didn't chomp the input. The regular expression matched by matching
the newline character to the pattern "anything that's not a carrot".

Quit wathcing Looney Tunes! Carrots aren't carats aren't carets... : )

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top