After looking over the docs (see links below) , I would use wild cards instead of regular expressions if your needs are simple enough:
location ~ \.(gif|png|jpg|jpeg)$ {
valid_referers none blocked server_names *.google.com *.bing.com *.yahoo.com *.feedburner.com;
expires 96h;
if ($invalid_referer) {
rewrite .* http://image-hosting.com/nohotlinking.png redirect;
}
}
Based on what I read I would expect that to work fine.
http://wiki.nginx.org/HttpRefererModule
http://nginx.org/en/docs/http/ngx_http_referer_module.html#valid_referers
http://linuxsysadminblog.com/2009/08/using-wildcards-in-nginx-valid_referers/