Use beginning-of-string and end-of-string Regexp anchors.

Avoids a vulnerability which can allow multiline Regexp statements to be evaluated as valid when they are indeed invalid. Changes multiline anchors to string-terminating anchors.