I’ve got text in a form of
[1/12/2008 2:32:11 p.m. - name] line 1 [1/12/2008 2:36:00 p.m. - name] - PRIVATE line 2 [some text] sd [1/12/2008 2:36:00 p.m. - name] line 3
which i want to split into items so i have access to time, name and text of each item,
e.g.: (item 1) 1: 1/12/2008 2:32:11 p.m. 2: name 3: line 1 (item 2) 1: 1/12/2008 2:36:00 p.m. 2: name 3: - PRIVATE line 2 [some text] sd (item 3) 1: 1/12/2008 2:36:00 p.m. 2: name 3: line 3
I was trying to come up with a single regex pattern to achieve this, but no luck:
\[([0-9\/ \:\.apm]+?) - ([a-z_\-0-9]+?)\](.*?\r\n.+?)(?:\[[0-9\/ \:\.apm]+? - [a-z_\-0-9]+?\])
This pattern above only returns the first item.
\[([0-9\/ \:\.apm]+?) - ([a-z_\-0-9]+?)\](.*?\r\n.+?)(?!\[[0-9\/ \:\.apm]+? - [a-z_\-0-9]+?\])
The pattern above returns all items, but only first character of the text (group 3)
Any suggestions?
It looks like this gets you what you want.
I tested it out on my RegEx tester and it appears to get the proper format.