Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Split without removing characters

by cmeyer (Pilgrim)
on Jun 17, 2005 at 19:54 UTC ( [id://467865]=note: print w/replies, xml ) Need Help??


in reply to Split without removing characters

Try using the zero-width look-behind and look-ahead matches:

@stuff = split /(?<=[a-z])(?=[A-Z])/;

This means that the regex matches at a point where there is a lowercase letter immediately preceding, and an uppercase letter immediately following, but neither of these letters are consumed by the match. More info: perlre

-Colin.

WHITEPAGES.COM | INC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://467865]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-24 18:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found