var layerName = layer.name;
//replace weird characters in layer names
var layerName = layerName.replace(")", "-");
var layerName = layerName.replace("(", "-");
var layerName = layerName.replace(":", "-");
var layerName = layerName.replace(":", "-");
var layerName = layerName.replace(/\//, "-");
var layerName = layerName.replace('/', "");
var layerName = layerName.replace("---", "-");
var layerName = layerName.replace("--", "-");
var file = new File(folder.fsName+"/"+layerName+".png");
using extendscript but for some reason it wont replace two "--" characters. I feel like I could do this easier with regex but I suck at those. am trying to replace all weird non alpha-numeric char and spaces with "-"