MrModest

Untitled

Mar 6th, 2021 (edited)
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const text = 'First note\n  \n---\nSecond note\n  \n---\nThird note';
  2.  
  3. const notes = text
  4.     .replace('/\n( +)\n/gm','\n\n')
  5.     .split('\n\n---\n')
  6.     .map(n => n.trim())
  7.     .filter(n => n);
  8.  
  9. console.log(notes);
Add Comment
Please, Sign In to add comment