regexp R如何找到<u00bf>

时间:2015-06-05 20:42:59

标签: regex r

如何使用正则表达式查找? 怎么写得正确?

我有这样的句子:

Alamofire.Manager

我只想删除Despite their ubiquity and importance in achieving high perfor<U+00BF>mance in modern processors... ,我已尝试过以下内容:

<U+00BF>

1 个答案:

答案 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