如何使用正则表达式查找? 怎么写得正确?
我有这样的句子:
Alamofire.Manager
我只想删除Despite their ubiquity and importance in achieving high perfor<U+00BF>mance in modern processors...
,我已尝试过以下内容:
<U+00BF>
答案 0 :(得分:1)
我知道您正在尝试从字符串中删除反转的问号¿
。
您可以使用\x
表示法来匹配十六进制值或文字:
sentence2 <- "¿Donde?"
gsub("\\xBF", "", sentence2)
// or
// gsub("\\xBF", "", sentence2, perl=T)
// or
// gsub("¿", "", sentence2)
这是demo
要删除<U+00BF>
,您需要转义+
:
sentence2 <- "Despite their ubiquity and importance in achieving high perfor<U+00BF>mance in modern processors..."
gsub("<U\\+00BF>", "", sentence2)
请参阅this demo