Start and End Anchors ^ $
Anchors don't match characters - they match positions in the text.
The Caret (^) - Start of String
^ matches the position at the start of the string.
Only the first "Hello" matches because it's at the start of the string.
The Dollar ($) - End of String
$ matches the position at the end of the string.
Exercises
Combining Anchors
Use both to match the entire string:
Validating Input
What Anchors DON'T Match
Anchors match positions, not characters:
The ^ matches the position before 'H', but captures no text (zero-length match).
Practice Playground
Try (with m flag for multiline):
^[A-Z]- lines starting with uppercase\.$- lines ending with period^\d- lines starting with digit^.+$- entire lines
Key Takeaways
^matches the start position$matches the end position- Use together for exact/full matches
- In multiline mode (
mflag), they match line starts/ends - Anchors don't consume characters

