Advertisement
-Annie-

EXAM-02.FormatHelper

Jun 14th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     "use strict";
  3.     let text = input[0];
  4.  
  5.     text = text.replace(/[.,!?:;]\s*/g, (match) => match.trim() + " ");
  6.     text = text.replace(/\s+[.,!?:;]/g, (match) => match.trim());
  7.     text = text.replace(/\.\s*\.\s*\.\s*\!/g, "...!");
  8.     text = text.replace(/(\.\s+)(\d+)/g,(match, gr1, gr2) => gr1.trim() + gr2);
  9.     text = text.replace(/\"([^\"]+)\"/g, (match, gr1) => `"${gr1.trim()}"`);
  10.  
  11.     console.log(text);
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement