Javascript split uniform expression

I am trying to create a javascript regex separation, but I am completely stuck. Here is my input:

9:30 pm
The user did action A.

10:30 pm
Welcome, user John Doe.

***This is a comment

11:30 am
This is some more input.

I want the output array after split () to be (I deleted it \nfor reading):

["9:30 pm The user did action A.", "10:30 pm Welcome, user John Doe.", "***This is a comment", "11:30 am This is some more input." ];

My current regex is:

var split = text.split(/\s*(?=(\b\d+:\d+|\*\*\*))/);

This works, but there is one problem: timestamps are repeated in additional elements. Therefore, I get:

["9:30", "9:30 pm The user did action A.", "10:30",  "10:30 pm Welcome, user John Doe.", "***This is a comment", "11:30", "11:30 am This is some more input." ];

I cannot split into new lines \n, because they are not consistent, and sometimes there can be no translation lines.

Could you help me using Regex for this?

Thank you so much!

EDIT: in response to phleet

It might look like this:

9:30 pm
The user did action A.

He also did action B

10:30 pm Welcome, user John Doe.

In principle, after a timestamp there may or may not be a new line, and there may be several lines of a new line to describe the event.

+5
1

, , Javascript split . , . :

/\s*(?=(\b\d+:\d+|\*\*\*))/

/\s*(?=(?:\b\d+:\d+|\*\*\*))/
        ^^

(?:___) - , .

, , . :

/\s*(?=\b\d+:\d+|\*\*\*)/


\*\*\* [*]{3}. . * , . {3} - , " 3 ".

+3

All Articles