You might get several different correct approaches to this, but this was my way of how I got your scenario to work.
1. First, create a Data Source to map to your custom dimension in the Google Universal Tag. In my example, my Data Source is called "urlpartial" which will be the final variable that will hold your string the way you described. In my example, I am mapping to custom dimension 1.
Then it replaces your single dashes, with an underscore (if dash exists using regular expression global setting) per your requirements as you described.
var fd=window.location.pathname.indexOf('--');//find double dash
fd=fd+2;//increment to start after double dash
var ld=window.location.pathname.lastIndexOf('-');//find last single dash
utag.data.urlpartial=tp.replace(new RegExp("-","g"), "_");
This worked in my sandbox and sends the string to custom dimension 1 of GUA.
I have some screenshots attached as well to show you how I did this in a second post below (as a .pdf file was only way I could attach the shots)
Hope this helps!
... View more