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
0 Response to Seperating a string into substrings (by upper case letters)
Post a Comment