Net Replace conversion problem, how to remove the $before and after id

encounter item.Selected conversion problem when revamping website
add "$" such as
< option selected= "selected" value= "$6$" > red < / option >
< option value= "$3$" > black < / option >
< option value= "$5$" > blue < / option >
< option selected= "selected" value= "$2$" > White < / option >
< option value= "$4$" > green < / option > <

Save the database code:
string Colors = string.Empty;
foreach (ListItem item in LBColor.Items) {
if (item.Selected) {

  Colors += item.Value+" ";

}
}
pro.Colors = Colors.Trim (). Replace (",",);

Save to the database with the above code, the value of colors is: $6 colors, 2 colors, 1 $.

ask for advice on how to remove $before and after id

Thank you

Mar.02,2021

Colors = Colors.Replace ("$", ").
PS: temporary variable begins with lowercase.


    var str = "$$$$";
    function stripscript(s) {
        var pattern = new RegExp("[`~!@-sharp$^&*()=|{}':;',\\[\\].<>/?~@-sharp&*|{} ';:" "']")
        //("[]")
        //("[$]")
        var rs = "";
        for (var i = 0; i < s.length; iPP) {
            rs = rs + s.substr(i, 1).replace(pattern, '');
        }
        return rs;
    }
    

call the above method of removing special symbols

alert(stripscript(str));

Menu