Monstar12 has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I have a string that has the characters ::: to split words , is it possible to split every 3rd occurrence with regex and place it into an array, example below.
How my array should look:my $string = "firstname1:::surname1:::middlename1:::firstname2:::surna +me2:::middlename2:::firstname3:::surname3:::middlename3"; my @arr;
Thanks.$arr[0] output: firstname1:::surname1:::middlename1 $arr[1] output: firstname2:::surname2:::middlename2 $arr[2] output: firstname3:::surname3:::middlename3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex split at number of occurrence
by tybalt89 (Monsignor) on Jul 02, 2018 at 15:17 UTC | |
by AnomalousMonk (Archbishop) on Jul 02, 2018 at 15:45 UTC | |
by Monstar12 (Initiate) on Jul 02, 2018 at 15:21 UTC | |
|
Re: Regex split at number of occurrence
by hippo (Archbishop) on Jul 02, 2018 at 16:14 UTC | |
|
Re: Regex split at number of occurrence
by AnomalousMonk (Archbishop) on Jul 02, 2018 at 15:35 UTC |