Man charged with trying to kill girlfriend