Ali,
A Contact header is a "name-address pair", so you first need to fetch the URI from it before you can fetch that URI's host portion. All of that can be done using Kamailio transformations:
http://www.kamailio.org/wiki/cookbooks/5.0.x/transformations
To accomplish what you'd want, you'd use:
$(ct{nameaddr.uri}{uri.host})
-- Alex