@eschwartz: FWIW (which isn't much) the way I mentally handle this problem is to remind myself that a replacement only occurs if the entire search pattern successfully matches against the source, and that in that case only the matched segment of the source is replaced. I often find myself sticking anchors and .*s in odd places to be sure that the pattern matches the entire source.
|