3
A
回答
6
你必須仔細逃脫(
與\\
。
x <- c("asdf", "asdf", "df", "(as")
x[!grepl("\\(", x)]
# [1] "asdf" "asdf" "df"
剛剛申請日是你的DF像df[!grepl("\\(", df$Name), ]
你也可以考慮通過使用正則表達式刪除所有puctuation字符:
x[!grepl("[[:punct:]]", x)]
正如@CSquare在評論中指出,here is a great summary about special characters in R regex
附加輸入從評論:
@Sotos:pattern='('
和fixed = TRUE
獲得表現,因爲正則表達式可以被繞過。
x[!grepl('(', x, fixed = TRUE)]
相關問題
- 1. 刪除行的特殊字符
- 2. 如何刪除特殊字符?
- 3. 如何刪除「Ctrl + Backspace」特殊字符?
- 4. 如何刪除所有特殊字符
- 5. 如何刪除特殊字符在python
- 6. 刪除特殊字符?
- 7. 刪除特殊字符
- 8. JSON刪除特殊字符
- 9. 刪除特殊字符php
- 10. Mawk - 刪除特殊字符
- 11. 特殊字符刪除'sed'
- 12. 刪除特殊字符SQL
- 13. 刪除特殊字符
- 14. 刪除特殊字符\
- 15. Mysql刪除特殊字符後出現特定特殊字符
- 16. 如何刪除以R中的特殊字符開頭的行
- 17. 刪除字典中的特殊字符
- 18. Excel宏刪除沒有特殊字符的行並從其他行中刪除特殊字符
- 19. 如何在PHP中刪除字符串中的特殊字符?
- 20. Java - 如何刪除字符串數組中的特殊字符?
- 21. 如何刪除帶有特殊字符的字符串結尾?
- 22. R如何刪除字符串中的特殊字符?
- 23. 如何刪除PHP字符串中的特殊字符?
- 24. (ASP.NET)如何在執行DateTime.Now.ToString()時刪除特殊字符
- 25. 如何在vi編輯器中刪除多行特殊字符
- 26. 刪除SQL中的特殊字符
- 27. 刪除特殊字符?從的.htaccess
- 28. 無法刪除str_replace的特殊字符
- 29. 刪除NSString中的特殊字符
- 30. 刪除Python中的特殊字符
的'('用grep的表達正則表達式的一部分,而不是作爲一個字符理解儘量躲避開括號:。'\\(',看看這是否會工作,你可以找到更多細節在這裏:https://stackoverflow.com/questions/27721008/how-do-i-deal-with-special-characters-like-in-my-regex – Deena
像這樣?df [!grepl(\\(, df $ Name),] – nemja