add begin and end line to regex if not there