【发布时间】:2022-06-10 22:58:10
【问题描述】:
知道为什么 R 不喜欢下面的正则表达式吗?
df %>% filter(!grepl("/ (call|cfd|equity option|equity swap|put|swap|trs)\s*$/i", y))%>%
filter(!grepl("/ (jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[0-9]{1,2} [0-9]+\.[0-9]+ ?[CP]\s*$/i", y))
Error: '\s' is an unrecognized escape in character string starting ""/ (call|cfd|equity option|equity swap|put|swap|trs)\s"
【问题讨论】:
-
你只需要两个反斜杠:
\\s。 R 处理的正则表达式与您在正则表达式指南中找到的略有不同
标签: r