Guest User

Untitled

a guest
Apr 25th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. var str = value.replace(/\s+/g, " ");
  2.  
  3. if (str.match(/^\S+\s\S+$/g)){
  4. var re = /^(\S+)\s+/;
  5. str.replace(re, "$1\r");
  6. };
  7.  
  8. else if (str.match(/^\S+\s\S+\s\S+$/g)){
  9. var re = /^(\S+)\s/;
  10. str.replace(re, "$1\r");
  11. }
  12.  
  13. else if (str.match(/^\S+\s\S+\s\S+\s\S+$/g)){
  14. var re = /^(\S+\s\S+)\s/;
  15. str.replace(re, "$1\r");
  16. };
Add Comment
Please, Sign In to add comment