I need to break a string into several strings by capital letters and acronyms, I could do this:
myString.scan(/[A-Z][a-z]+/)
But it works for only capital letters, in cases like:
QuickFoxReadingPDF
or
LazyDogASAPSleep
The all-capital acronyms are missing in the result.
What should I change the RegEx to, or are there any alternatives?
Thanks!
Update:
Later I found some of my data has digits, like "RabbitHole3", It would be great if the solution could consider digits, ie. ["Rabbit", "Hole3"]
.
Use
See proof.
Explanation
Ruby code:
Results:
["Quick", "Fox", "Reading", "PDF"]