Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Thanks for looking!#!/usr/bin/perl use strict; use warnings; use Data::Dumper qw(Dumper); # Test cases: my $string_a = "Joe Dolly"; # It should split and print JD. my $string_b = "perl.pl"; # It should match on the regular expressio +n and nothing prints. my $string_c = "States"; # It should match on the regular expressio +n and nothing prints. my @got = $search_c =~ /^(?!\w)|(\.[^.]+)$/ig ? [] : split //, $string +_c; print Dumper $got[0]; print Dumper $got[1];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Split string only on regular expression match
by Athanasius (Archbishop) on Oct 31, 2017 at 16:23 UTC | |
by Anonymous Monk on Oct 31, 2017 at 17:13 UTC | |
|
Re: Split string only on regular expression match
by hippo (Archbishop) on Oct 31, 2017 at 16:16 UTC | |
by Anonymous Monk on Oct 31, 2017 at 17:17 UTC | |
by Anonymous Monk on Oct 31, 2017 at 17:52 UTC |