2016-02-12 28 views
2

在R,我已內編碼的垃圾字符串,如R:從一個字符串中刪除所有編碼的文本

"based on the unique spectral \xfc\xbe\x8e\x93\xa0\xbc\xfc\xbe\x98\xa6\x90\xbc\xfc\xbe\x99\xa6\x8c\xbcfingerprints\xfc\xbe\x8e\x93\xa0\xbc of their biochemical composition" 

有一種簡單的方法來剝去編碼垃圾的字符串,不管是什麼垃圾是?

回答

4

使用gsub

x <- "based on the unique spectral \xfc\xbe\x8e\x93\xa0\xbc\xfc\xbe\x98\xa6\x90\xbc\xfc\xbe\x99\xa6\x8c\xbcfingerprints\xfc\xbe\x8e\x93\xa0\xbc of their biochemical composition" 
gsub("[^[:print:]]", "", x) 
# [1] "based on the unique spectral fingerprints of their biochemical composition" 
+0

還沒有看到ü一會兒。加一。 – akrun

相關問題