Hi everyone,
I am trying to extract a portion of text variable. My aim is to take the characters after "aa:" until "f". (or until a pre-specified word) Below is my simplified code:
gen text = ""
replace text = "aa: inffant bb: insp cc: 35 yrd old. dd: ee:acad" in 1
replace text = "aa: infant ff:no fnote bb: insp cc: 35 yrd old. dd: ee:acad" in 2
gen trial = ""
replace trial = regexs(1) if regexm(text, "aa[. #:-]*([a-z0-9.,&/: ]*)(f)")
My outputs for this code is as follows:
Row 1: inf
Row 2: infant ff:no
Why does it happen? I mean why I do not get "in" for both of them, and also why I get "inf" for the first one although I get "infant ff:no" for the second one?
I appreciate your helps in advance.
Best,
Ulas
I am trying to extract a portion of text variable. My aim is to take the characters after "aa:" until "f". (or until a pre-specified word) Below is my simplified code:
gen text = ""
replace text = "aa: inffant bb: insp cc: 35 yrd old. dd: ee:acad" in 1
replace text = "aa: infant ff:no fnote bb: insp cc: 35 yrd old. dd: ee:acad" in 2
gen trial = ""
replace trial = regexs(1) if regexm(text, "aa[. #:-]*([a-z0-9.,&/: ]*)(f)")
My outputs for this code is as follows:
Row 1: inf
Row 2: infant ff:no
Why does it happen? I mean why I do not get "in" for both of them, and also why I get "inf" for the first one although I get "infant ff:no" for the second one?
I appreciate your helps in advance.
Best,
Ulas
Comment