Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Splitting multiple commands with regex failure

by moritz (Cardinal)
on Aug 24, 2012 at 07:48 UTC ( #989444=note: print w/ replies, xml ) Need Help??

in reply to Splitting multiple commands with regex failure

For splitting the commands, you can split before a ! sign

use strict; use warnings; my $command = '!book this is my test book !number 1222223 !book anothe +r book"'; my @commands = split /(?=!)/, $command;

Then if you want to ignore all but the first command, just use $commands[0]

This leaves trailing spaces in the commands. If you want to remove those too, split on /\s*(?=!)/ instead.

Comment on Re: Splitting multiple commands with regex failure
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://989444]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2015-11-28 20:56 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (744 votes), past polls