Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2014-07-31 05:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (245 votes), past polls