How to rewrite the url when regex NOT match a pattern

I would like to translate below nginx code, which is when the url does not match a regex, i.e. http://IP/123, to redirect/write to http://IP/abc/123

    if ( $request_uri ~ ^/abc/(.*)$ ) {
        proxy_pass          http://192.168.31.214:8081/abc/$1;
    }