http://www.perlmonks.org?node_id=989440


in reply to Splitting multiple commands with regex failure

Hi,

To start with check this line:

if $command ne "") { ## Oops ... ### should be if ($command ne "") { ...
..(It parses the first parameters, like "command=!book this is my test book !number 1222223 !book another book" will just split out "!book this is my test book", and ignore the rest.

If you want just !book this is my test book, then you might have to check your regex again!!!
Beacuse this: m/(!\w+\s?.+?)(?=!\w)/simg; was just doing it job. Really.

Please also check this: # (!\w+\s?)(.+?(?=!\w)) is the original regex I was using
That was no where in your code as indicated in the original post. so this print "Command 3 is $3\n\n"; will cry foul!!! As this m/(!\w+\s?.+?)(?=!\w)/simg; is not equal to m/(!\w+\s?)(.+?(?=!\w))/;
Knowing that your data is unknown.