Do
view release on metacpan or search on metacpan
lib/Data/Object/String.pm view on Meta::CPAN
$string->snakecase; # hello_world
=back
=cut
=head2 split
split(RegexpRef $arg1, Num $arg2) : ArrayObject
The split method splits the string into a list of strings, separating each
chunk by the argument (string or regexp object), and returns that list as an
array reference. This method optionally takes a second argument which would be
the limit (number of matches to capture). Note, this operation expects the 1st
argument to be a Regexp object or a String. This method returns a
array object.
=over 4
=item split example
t/0.01/data/object/string/split.t view on Meta::CPAN
use strict;
use warnings;
use Test::More;
use_ok 'Data::Object::String';
# deprecated
# can_ok 'Data::Object::String', 'split';
use Scalar::Util 'refaddr';
subtest 'test the split method' => sub {
my $split;
my $string = Data::Object::String->new('name, age, dob, email');
$split = $string->split(qr/\,\s*/);
is_deeply $split, ['name', 'age', 'dob', 'email'];
isa_ok $string, 'Data::Object::String';
isa_ok $split, 'Data::Object::Array';
$split = $string->split(qr/\,\s*/, 2);
is_deeply $split, ['name', 'age, dob, email'];
t/0.90/can/Data_Object_String_split.t view on Meta::CPAN
# given 'name, age, dob, email'
$string->split(', '); # ['name', 'age', 'dob', 'email']
$string->split(', ', 2); # ['name', 'age, dob, email']
$string->split(qr/\,\s*/); # ['name', 'age', 'dob', 'email']
$string->split(qr/\,\s*/, 2); # ['name', 'age, dob, email']
=description
The split method splits the string into a list of strings, separating each
chunk by the argument (string or regexp object), and returns that list as an
array reference. This method optionally takes a second argument which would be
the limit (number of matches to capture). Note, this operation expects the 1st
argument to be a Regexp object or a String. This method returns a
array object.
=signature
split(RegexpRef $arg1, Num $arg2) : ArrayObject
( run in 0.707 second using v1.01-cache-2.11-cpan-71847e10f99 )