Welcome to the wild world of regular expressions. May your code be as smooth as silk, but not too smooth, for that's just boring.
Regular expressions are like a good friend: they're only as good as you are at understanding them. And if you don't understand them, they might just bite you.
Let's start with the basics. You see, anchors are like the 'A' in 'Anchors Aweigh.' They keep things from floating away, but only if you tie them down properly.
In regular expressions, anchors are the ^ symbol at the start of a pattern and the $ at the end. They tell the engine to match from here or to here, but not from anywhere in between. Got it?
So, what do you want to learn first? How about how to match the start of a line?
Anchor Pattern Matching: Matching the Start of a Line, or maybe you want to know about matching the end of a line?
Anchor Pattern Matching: Matching the End of a Line
Anchor Pattern Matching: Matching Anywhere, or maybe you just want to learn how to make anchors do your bidding?