What's happening when you're using the square brackets is that you're defining character classes. So in the second example, it uses the outer set of square brackets to mark out a character class that is: []word[] (which is equivalent to dorw[]).