^ and $ are a little different in grep and rex since grep is line oriented and rex isn't. ^ and $ mean the actual newline character(s) in rex whereas they are buffer anchors in grep. Rex uses >>= for buffer anchor (same on either end). You need expression anchors (>>) when you're assuming matching in a particular direction. Without one rex is free to search backwards if that's more efficient.