Help with migrating from DotNetNuke to WordPress


I am currently in the process of migrating a blog that is based on IIS8 and DotNetNuke. As things are right now the URLs for images contain spaces in them.

An example URL would be

What I want is for the new site URL for images to be

Can someone here help me with the regex and rewrite tools necessary for this? From my research the closest result i found is converting “_” to “-” using the code below.

location ~ _ {
  rewrite ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5-$6-$7-$8-$9;
  rewrite ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5;
  rewrite ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3;
  rewrite ^([^_]*)_(.*)$ $1-$2;
  rewrite ^ $uri permanent;