haolecoder has asked for the wisdom of the Perl Monks concerning the following question:
I want to use '**' as the delimiter. Here is my code to split this string:my $str = "123**abc******";
Which gives me the following:my @values = split(/\*\*/,$str); warn Dumper(\@values);
What I need it to return is this (so that the two trailing '**' are also split, but it just gives an empty value):$VAR1 = [ '123', 'abc' ];
Is this possible to do with split?$VAR1 = [ '123', 'abc', '', '' ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Split a string with multiple trailing delimeters?
by kennethk (Abbot) on Jan 04, 2011 at 18:45 UTC | |
by haolecoder (Initiate) on Jan 04, 2011 at 18:59 UTC | |
|
Re: Split a string with multiple trailing delimeters?
by BrowserUk (Patriarch) on Jan 04, 2011 at 18:41 UTC | |
by Fletch (Bishop) on Jan 04, 2011 at 18:47 UTC | |
by haolecoder (Initiate) on Jan 04, 2011 at 18:57 UTC | |
|
Re: Split a string with multiple trailing delimeters?
by ikegami (Patriarch) on Jan 04, 2011 at 19:04 UTC | |
|
Re: Split a string with multiple trailing delimeters?
by logix (Initiate) on Jan 04, 2011 at 19:19 UTC | |
|
Re: Split a string with multiple trailing delimeters?
by mikeraz (Friar) on Jan 04, 2011 at 19:34 UTC |