Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
141
rated 0 times [  143] [ 2]  / answers: 1 / hits: 18487  / 12 Years ago, fri, march 23, 2012, 12:00:00

I want to split a string with all non-alphabetic characters as delimiters.



For example, I want to split this string



hello1 twenty-three / nine.bye


into



[hello,,twenty,three,,,nine,bye]


I've tried this



text.split(/[A-Za-z]+/)


but it isn't working.



How do I split a string by non-alphabetic characters?


More From » string

 Answers
114

It sounds like you're looking for the not a match atom: [^. Try the following



text.split(/[^A-Za-z]/)

[#86639] Thursday, March 22, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
grayson

Total Points: 36
Total Questions: 113
Total Answers: 95

Location: Tonga
Member since Fri, Aug 21, 2020
4 Years ago
grayson questions
;