I have a string and am trying to findout what’s a better way by
replacing (the boundry spaces as well if they exist)
while also replacing the value without
doing multipule passes (ie calling, trim_multispace and trimed_result).
var replaceVal = "c";
var strVals = "a b c d e f g h";
var replacedVal = strVals.replace(new RegExp("\\b"+replaceVal+"\\b",""),"");
alert(replacedVal)
var trim_multispace = replacedVal.replace(/ +(?= )/g,'');
var trimed_result = trim_multispace.replace(/^\s+|\s+$/g, '');
alert(trimed_result)
I am not sure if I got you correctly, but this regex works in the way you specified