Hi,
We have a control system, which sends automated messages in the following syntax:
##TO admin, user1, user2
message1
##TO user2, user4
message2
##TO user5
message3
I think the syntax is obvious. From this message I need to create as many messages as many different users are after the ##TO fields. In this case admin, user1, user2, user4 and user5. Each user must get all the messages where they are addressed in ##TO fields. In this case admin and user1 get message1; user2 gets message1 + message 2; user4 gets message 2; user5 gets message3. All messages can contain many sentences, newlines, empty lines but no special characters except [ and ].
After ##TO there must be one or more spaces/tabs and a username. In case of more usernames: after the first username zero, one or more spaces/tabs followed by a colon and zero, one or more spaces/tabs and the next username. There is no limit for the number of usernames, but generally 5-6 is the max in one ##TO field.
I need to find a PHP4 preg_match or preg_match_all regexp which generate the array from where I can easily link messages to users and send the relevant messages to each user.
Thanks in advance.