fork download
  1. var re = /([^(]*)(\(.*?\(?.*?\).*?\))/g;
  2. var str = 'Some notes(SOME USER (SU950) 16/09/2015 16:56:38)Some other notes(ANOTHER > USER (AU951) 16/09/2015 16:56:38)\n\nExample Notes Type:OUTBOUND CALL BACK (USER NAME (UN973) 18/09/2015 11:49:10)\n\nsome notes on multiple lines\n\nsecond line of notes (USER NAME (UN973) 18/09/2015 11:52:24)\n\nA new note. (USER NAME (UN973) 18/09/2015 11:55:15)';
  3. var m;
  4.  
  5. while ((m = re.exec(str)) !== null) {
  6. if (m.index === re.lastIndex) {
  7. re.lastIndex++;
  8. }
  9. print(m[0]);
  10. print(m[1]);
  11. print(m[2]);
  12. }
Success #stdin #stdout 0.4s 321920KB
stdin
Standard input is empty
stdout
Some notes(SOME USER (SU950) 16/09/2015 16:56:38)
Some notes
(SOME USER (SU950) 16/09/2015 16:56:38)
Some other notes(ANOTHER > USER (AU951) 16/09/2015 16:56:38)
Some other notes
(ANOTHER > USER (AU951) 16/09/2015 16:56:38)


Example Notes Type:OUTBOUND CALL BACK (USER NAME (UN973) 18/09/2015 11:49:10)


Example Notes Type:OUTBOUND CALL BACK 
(USER NAME (UN973) 18/09/2015 11:49:10)


some notes on multiple lines

second line of notes (USER NAME (UN973) 18/09/2015 11:52:24)


some notes on multiple lines

second line of notes 
(USER NAME (UN973) 18/09/2015 11:52:24)


A new note. (USER NAME (UN973) 18/09/2015 11:55:15)


A new note. 
(USER NAME (UN973) 18/09/2015 11:55:15)