代码之家  ›  专栏  ›  技术社区  ›  rane

如何在逻辑或regex操作中换行[重复]

  •  1
  • rane  · 技术社区  · 8 年前

    目标是通过 特征线 逻辑或正则表达式

    例子

    GG <- c("aa","bb")
    

    正常表达式

    grepl("aa"|"bb",GG)
    
    [1]  TRUE TRUE # --- It is what i want
    

    特征线表达式

    grepl("aa"|
          "bb",GG)
    
    [1]  TRUE FALSE # --- Not able the find all the result
    

    如何 特征线 当多个条件 长字符串 是吗?

    (实际所有字符串如下:

    "Health Attention Senior Department Session One |
    Product Development Division Number Six|
    Management and Risk Controller Department Number Seven"
    

    )太长,无法将它们全部包含在一行脚本中

    1 回复  |  直到 8 年前
        1
  •  4
  •   PKumar    8 年前

    (?x)

    grepl("(?x)aa|
            bb",GG, perl=TRUE)
    

    #> grepl("(?x)aa|
    #+         bb",GG, perl=TRUE)
    #[1] TRUE TRUE
    

    来自文档:

    相当于Perl的s/s)和(?x)(扩展的空白数据 相当于Perl's/x)

    here