【问题标题】:R regular expression -- escapeR 正则表达式——转义
【发布时间】: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


猜你喜欢
  • 2013-01-18
  • 2011-10-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多