Given the following text:
[chat] somebody: this is some text that needs to be matched.
it continues on this line with four spaces at the bottom
and its also on this line.
It should not match this line
[chat] somebody: this is more text, but only one line.
This should not be matched
Each message I'm trying to process can extend onto the next line, but if it does so, it the next line will start with four spaces. So far I've come up with the following regular expression, which stops at a newline, but I can figure out how to get the match to continue.
(^|\r|\n)\[([a-z]+)\]\s+([a-z]+):?\s+([^\n]+)
I've also tried:
(^|\r|\n)\[([a-z]+)\]\s+([a-z]+):?\s+(.+?\n[^ ]+)
Which partially works, but still matches the first word on the incorrect lines.
Any suggestions as to how I could do this with a regular expression?