I have a macro listing variables including factor variables -- e.g.,
The regexm() function can match all prefixes with wildcards, like this --
What do I need? Thanks!
local covariates x i.y ib1.zI would like to remove the prefixes i., ib1. etc. I can remove the prefixes one at a time using the subinstr function, like this.
local covariates x i.y ib1.zBut if there are a lot of different prefixes, it is clunky to remove them one a time.
local covariates_clean = subinstr("`covariates'","i.","",1000)
local covariates_clean = subinstr("`covariates_clean'","ib1.","",1000)
di "`covariates_clean'"
The regexm() function can match all prefixes with wildcards, like this --
local covariates x ib.y ib1.z i.zz--but it only replaces the first match.
local covariates_clean = regexr("`covariates'","i[^\.]*\.","")
di "`covariates_clean'"
What do I need? Thanks!
Comment