Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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 meditating upon the Monastery: (8)
As of 2015-07-04 14:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls