const val = '> - - пример ---' let re = /(\s){2,}/g alert(val.replace(re, '$1')) re = /(-){2,}/g alert(val.replace(re, '$1'))