Dear all,
I have to "cut a string into pieces". The "seperator" being a upper case letter.
e.g. var name "AbrahamAndyGregor" should be divided in var name1 "Abraham" var name2 "Andy" and var name3 "Gregor".
There are about 180 "names" combined in different ways. I do have a list of names.
What I tried was to set the first letter to lower case -->
gen name1=(lower(substr(name, 1, 1))) + (substr(name, 2, .)) ---> name will be abrahamAndyGregor.
Thus I could extract the first name ...
gen name1 = regexs(0) if regexm(name, "[a-zäöüß ]+")
(Those freaky letters äöüß are just because they appear in the names - also blanks).
Then I tried to get the second name - and failed ;-)!
I tried different combinations like ...
gen name2 = regexs(1) if regexm(name, "(([a-zäöüß ]+)([A-ZÄÖÜ][a-zäöüß ]+))")
gen name2 = regexs(0) if regexm(name, "([A-ZÄÖÜ][a-zäöüß ]+)")
Asking the forum kindy for help - best regards,
Lynde
Related Posts with Seperating a string into substrings (by upper case letters)
spmap point data: Display Alaska and Hawaii next to contiguous United StatesDear Users, I want to draw a point map with locations of firms by coordinates displaying Alaska and …
Appending datasets of different shapesHi, I have datasets from 3 surveys with the first one containing variables like unique ID, age, BMI…
sample size calculation when there are three groups Hi, We are planning to conduct an RCT comparing nitroglycerine patches to decrease the failure rat…
Help needed in creating bar charts of selected countriesHi, I would need some help in creating bar charts that look like this: Array This is what my data…
Fixing a sample so observations between specifications are the same to enable comparisonsIn my regressions, I add variables across five specifications in which the last contains all the var…
Subscribe to:
Post Comments (Atom)
0 Response to Seperating a string into substrings (by upper case letters)
Post a Comment