that seems to be the case based on a wide variety of queries using ^ inside ['s
whereas outside []s a ^ seems to only mean the start of a string

is that correct Shannon? Boy I love learning perl. What a freako I am.

KevinADC

07-20-2009, 05:58 PM

That's correct. What you have is called a negated character class. It means to not match what is inside the character class, in this case white space. But it will match everything else that is not inside the character class, so any non-white space will be matched.

You will find some explanations and examples here as well as in your book:

http://perldoc.perl.org/perlretut.html#Using-character-classes

Philip M

07-20-2009, 07:28 PM

([^ ]+) means match one or more characters which are not a space

([^\W]+ means match one or more characters which are not a-zA-Z0-9_
which is not exactly the same thing.

^ within square brackets means "not". Otherwise ^ means start of the string, and $ means the end of the string.

/^(Philip)/ matches Philip at the start of the string

[^xyz] matches anything which is not an x, a y or a z.

To swap two words in a string such as firstname lastname (Javascript):-