How to assert that a string has a newline character and, if so, remove it

I have a string that is the result of some operation I have no control over. When I print this variable using echo, I get: echo $myvar hello However, when I do if [ $myvar = "hello" ]; then ...