[Israel.pm] split

Yossi.Itzkovich at ecitele.com Yossi.Itzkovich at ecitele.com
Tue Feb 24 01:14:07 PST 2004

But I don't the delimiter as a seperate element in the return list. As I
showed in the example:
For the string  "deabcamn" , and using the delimiter "a" , I want to get :
qw(de abc amn).


                      Yuval Kogman                                                                                                 
                      <lists at woobling.         To:      Perl in Israel <perl at perl.org.il>                                          
                      org>                     cc:                                                                                 
                      Sent by:                 Subject: Re: [Israel.pm] split                                                      
                      perl-bounces at per                                                                                             
                      02/24/2004 11:00                                                                                             
                      Please respond                                                                                               
                      to Perl in                                                                                                   

On Tue, Feb 24, 2004 at 10:51:11 +0200, Yossi.Itzkovich at ecitele.com wrote:

> Hi,

Hi ho!

> Is there a way to get split()  to return the delimiter too ?

Yes, just capture what you want to keep

             split /(\s+)/;

for example, will make a list of $_, which will look like

             "foo"," ","bar"

if $_ was "foo bar".

Ciao ciao!

 ()  Yuval Kogman <nothingmuch at woobling.org> 0xEBD27418  perl hacker &
 /\  kung foo master: /me sushi-spin-kicks : neeyah!!!!!!!!!!!!!!!!!!!!

Perl mailing list
Perl at perl.org.il


More information about the Perl mailing list