JavaScript regular expression to replace a sequence of chars
问题 I want to replace all spaces in the beginning and the end of a string with a underscore in this specific situation: var a = ' ## ## # '; console.log(myReplace(a)); // prints ___## ## #__ i.e.: all the spaces in the beginning of the string before the first # and all the spaces after the last #, everything else (including spaces in the middle of the string) remains untouched. My initial thinking was to use two Reg Exp, one for each part of the problem. However, I couldn't get the first one and