Bubblegum
view release on metacpan or search on metacpan
lib/Bubblegum/Object/String.pm view on Meta::CPAN
modifies the subject.
=head2 split
my $string = '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']
The split method splits the subject 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.
=head2 strip
my $string = 'one, two, three';
$string->strip; # one, two, three
t/bubblegum/object/string.t view on Meta::CPAN
};
can_ok 'Bubblegum::Object::String', 'snakecase';
subtest 'test the snakecase method' => sub {
my $string = 'hello world';
is 'helloWorld', $string->snakecase; # helloWorld
is 'helloWorld', $string; # helloWorld
};
can_ok 'Bubblegum::Object::String', 'split';
subtest 'test the split method' => sub {
my $string = 'name, age, dob, email';
is_deeply $string->split(qr/\,\s*/), # ['name', 'age', 'dob', 'email']
['name', 'age', 'dob', 'email'];
is_deeply $string->split(qr/\,\s*/, 2), # ['name', 'age, dob, email']
['name', 'age, dob, email'];
is_deeply $string->split(', '), # ['name', 'age', 'dob', 'email']
['name', 'age', 'dob', 'email'];
is_deeply $string->split(', ', 2), # ['name', 'age, dob, email']
['name', 'age, dob, email'];
};
( run in 0.508 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )