Connection Test Script

I am writing a script to do some conditional logic based on the results of a connection test. I need to capture the output of netcat, the 3 expected conditions are as follows. I need to capture the output of this command. I could write this to a file, but I would like to do it clearer if possible.

nc -w 2 -nzv 127.0.0.1 80-80
(UNKNOWN) [127.0.0.1] 80 (?) : Connection refused

nc -w 2 -nzv 127.0.0.1 80-80
(UNKNOWN) [127.0.0.1] 80 (?) : Connection timed out

nc -w 2 -nzv 127.0.0.1 80-80
(UNKNOWN) [127.0.0.1] 80 (?) open

basically I am looking for

if "refused" then x
if "timed out" then y
if "open" then z

But I don't know how to capture the results of the netcat.

I appreciate any help you can provide.

variable=`nc -w 2 -nzv 127.0.0.1 80-80 2>&1`
do something with $variable