我在R中有一个包含大量单词的字符串。当查看该字符串时,会得到大量文本,其中包括类似以下文本:
>docs
....
\u009cYes yes for ever for ever the boys cried in their ringing voices with softened faces
....
我在想如何从字符串中删除这些\u009字符(其中一些具有略微不同的数字)。我尝试使用gsub()
,但它无法有效地从字符串中删除内容。
这应该可以工作
gsub('\u009c','','\u009cYes yes for ever for ever the boys ')
"Yes yes for ever for ever the boys "
这里的009c是Unicode的十六进制数,你必须始终指定4个十六进制数字。 如果你有很多,一个解决方案是用管道符号分隔它们:
gsub('\u009c|\u00F0','','\u009cYes yes \u00F0for ever for ever the boys and the girls')
"Yes yes for ever for ever the boys and the girls"
try:
gsub('\\$', '', '$5.00$')
gsub(' |-', '', ' 1-444-654 ')
- Zak