I just came accross the following problem: suppose you have a string variable (stringvar
) which contains text and question marks. Question marks are usually used as wildcards for single letters or numbers. So, when you want to apply some changes to the variable (here: removing the “?”), you should NOT type
replace stringvar = regexr(stringvar,"?","")
or
replace stringvar = regexr(stringvar,"`?'","")
In this case, any character of stringvar
would be replaced. The variable would have no observations. Instead you have to add a backslash right in front the question mark:
replace stringvar = regexr(stringvar,"\?","")
Leave a Reply
You must be logged in to post a comment.