perl split

XK8ER
XK8ER used Ask the Experts™
on
hello there,
I have a string and I would like to know if its possible to have a split at every char that its not a letter..
how can I do that?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ozo
Most Valuable Expert 2014
Top Expert 2015

Commented:
split/\W/
or
split/[^a-zA-Z]/
split/\W/   # Will also split at digits and "_", of course
split/[^a-zA-Z]/  # Could be written slightly more concisely as:
split/[^a-z]/i

You taught me too well, ozo...I hope
Most Valuable Expert 2014
Top Expert 2015
Commented:
it is also possible that the XK8ER meant to ask for
split/[^a-z]+/i
rather than
split/[^a-z]/i
ozo
Most Valuable Expert 2014
Top Expert 2015

Commented:
the difference between split/[^a-z]+/i and split/[^a-z]/i
is that when you split at every char that its not a letter,
then multiple non-letters in a row will return the empty strings in between the non-letters

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial