Input:
\". . . . .\"
Expected output:
try
result = str.replace(/^\s+|\s+$/g,'').replace(/\s+/g,' ');