Skip to content

How to replace 'star (*)' with blank space?

3 messages · Ruby Chu, Uwe Ligges, David Winsemius

#
gsub("\\*", " ",x)

should do. Please read about regular expression as used by gsub().

Uwe Ligges
On 20.04.2011 12:00, Ruby Chu wrote:
#
On Apr 20, 2011, at 6:00 AM, Ruby Chu wrote:

            
"*" is an operator in regex, so you need to double escape it in the  
pattern argument (but may not need to escape it in the replace argument.

 > gsub("\\*", "", "test8888****8888****9999")
[1] "test888888889999"

 > gsub("\\.", "*", "test8888...8888...9999")
[1] "test8888***8888***9999"
David Winsemius, MD
West Hartford, CT