Reputation: 87
This is one the first string split occasions that I'm not sure can be accomplished in R.
I have a list of strings containing information in the form:
data <- c("Los Angeles DodgersAtlanta Braves",
"Milwaukee BrewersChicago Cubs",
"Arizona DiamondbacksMiami Marlins")
How would I go about splitting the two adjoining team names in each string?
Is there a way to find or split based on the capitalization of a string?
(Maybe a way to find when two lowercase characters precede a capital and split there? )
Upvotes: 1
Views: 291
Reputation: 11051
Split with the following regex:
(?:\s|(?<=[a-z]))(?=[A-Z])
Here is a regex demo.
Upvotes: 4