In Ruby regular expressions, the ^ character is used to denote the beginning of the String. The the following…

a = 'abcde'
s.match(/^a/)

…returns true/makes a match because the string s begins with the character “a”. But if you want to match on all characters that are not “a”, how do you do it?

s.match(/[^a]/)

Once ^a is placed inside of the square brackets it becomes a character class where the ^ character acts as negation rather than beginning-of-string.

I’m sure most people who pay attention picked this up the first time reading through a Ruby book, but I don’t pay 100% attention all the time and this minor detail slipped by.