Advertisement
fbinnzhivko

Untitled

Dec 17th, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve([text]) {
  2.     console.log(text
  3.         .replace(/([.,!?:;])\s*/g,  (match, g) => g + ' ')
  4.         .replace(/\s+([.,!?:;])/g, (match, g) => g)
  5.         .replace(/\.\s*\.\s*\.\s*!/g, '...!')
  6.         .replace(/\.\s+(\d+)/g, (match, g) => '.' + g)
  7.         .replace(/"([^"]+)"/g, (match, g) => `"${g.trim()}"`));
  8. }
  9. solve(['Terribly formatted text . With chaotic spacings." Terrible quoting "! Also this date is pretty confusing : 20 . 12. 16 .  ']);
  10. solve(['Make,sure to give:proper spacing where is needed... !']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement