input str20 name
"ABC- A - D"
"A -ABD - D"
"A-A - D"
"A-b - D"
"b-A - D"
end
I would like to cleanse the data by removing the hyphens between two characters or a character and a space. In other words, I want to cleanse my data into
input str20 name
"ABC A - D"
"A ABD - D"
"A A - D"
"A b - D"
"b A - D"
end
That is, replace the hypthen with a space at the same time preserving the characters.
I have tried something like
gen help1 = regexs(1) if regexm(name, "[a-zA-Z]-[a-zA-Z]")
gen help2 = regexr(name, "-", "")
gen help2 = regexr(name, "-", "")
0 Response to regexr - Regular Expression in Stata
Post a Comment