I have a multicentric study whose location has been imported. For example "Netra Jyothi Charitable Trust, C/o Prasad Netralaya Super specialty Eye Hospital,KARNATAKAYenepoya Medical College Hospital,KARNATAKA". I want to split "KARNATAKAYenepoya" in-between "KARNATAKA" and "Yenepoya". I am unable to create the code in such a way that it will automatically detect if there is any state name in caps like "KARNATAKA" and make a split after that.
I have tried using the code:
text <- "KARNATAKAYenepoya"
state_name <- str_extract(text, "[A-Z]+")
print(state_name)
But I am getting the value "KARNATAKAY" instead of "KARNATAKA".
In your and a few similar cases try this one:
Which output will be: