Disallowing repeated characters and space after punctuation
Prevent repetead characters (all kind of characters) to 3.


If you mean replace 4 or more repeated characters with single character:

str.replace(/(.)\1{3,}/g, '$1');





  Add space after commas (,) or any kind of punctuation (!) (?) (.)


str.replace(/[,.!?:;](?=\S)/g, '$&amp; ');