Javascript split with RegEx
- by Rohan
Hey again,
I just asked a question about Regex, and received a great answer: http://stackoverflow.com/questions/3047201/javascript-split-without-losing-character
Now, I have another question.
My current Regex looks like this:
var split = text.split(/(?=\w*\d*\d:\d\d)/);
Basically, I'm trying to split using the timestamps (eg - 9:30 or 10:30, the difference between them is the extra digit in the latter). How do I go about this?
Currently, if I have these two:
9:30 pm
The user did action A.
10:30 pm
Welcome, user John Doe.
The splits are :
9:30 pm
The user did action A.
----
1
----
0:30 pm
Welcome, user John Doe.
How do I add an optional check for the first character in the timestamp?
Thanks!