I have data for tasks that were recorded using a schedule application. I am trying to parse breaks for each task.
An example of an interrupt line attached to a task might look like this:
1:19 pm - 10:33 pm ate tacos 10:35 pm - 11:38 pm 12:40 am - 1:24 am took a pile
I need to group this into timestamps with related descriptions. The above should be grouped as follows:
1:19 pm - 10:33 pm ate tacos
10:35 pm - 11:38 pm
12:40 - 1:24 in the morning took a nap
The description of the interrupt interval can contain basically any characters or be of any length. Some intervals have no descriptions.
I believe that regex will be the easiest way to get an array of intervals with their descriptions (if any).
So far I:
\d{1,2}:\d{2}[ap]m\sβ\s\d{1,2}:\d{2}[ap]m
which corresponds to the timestamps 1:19pm β 10:33pm , 10:35pm β 11:38pm and 12:40am β 1:24am
I use JavaScript and match to parse this data. I want to make a regex that matches the timestamp and everything that follows it until the next timestamp.
I start with regex, so it's easy on me. I was in this for hours, watched several videos, read blogs for textbooks and experimented with regex101 . Anchors, looks / nape, are confusing, and I can not get anything to do what I want. Not wanting to become an expert in writing regular expressions, but I would really like to learn something new that can be directly applied to what I do.
javascript regex timestamp
jgoodhcg
source share