I assume you mean you're using split(m/[A-Z]/, $string), but you didn't make that very clear.
The split() pattern defines what to remove between the chunks you want to keep. Using a m// pattern with captures defines what to keep amongst the rest of the string.
This method catches a list of capitalized chunks, and is the more natural to me:
my $name = 'JohnJacobJingleheimer-Schmidt'; my @chunks = ($name =~ m/([A-Z][a-z]*)/g); print $_,$/ for @chunks;
By using a couple of zero-width assertions, you could use split(), but it will act differently with punctuation cases:
my $name = 'JohnJacobJingleheimer-Schmidt'; my @chunks = split(m/(?<=[a-z])(?=[A-Z])/, $name); print $_,$/ for @chunks;
--
[ e d @ h a l l e y . c c ]
In reply to Re: split by a capital followed by
by halley
in thread split by a capital followed by
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |