Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 chanting in the Monastery: (13)
As of 2014-08-21 21:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (143 votes), past polls