use \A and \Z instead of ^ and $