Skip to content

str_match and str_match_all behave inconsistently when groups are missing #134

Closed
@kindlychung

Description

@kindlychung

Here is an example:

  string = "-3e9, 9E-2"
  pattern <- "([+-]?)(\\d+)(\\.\\d+)?[eE]([+-]?)(\\d+)"
  stringr::str_match_all(string = string, pattern = pattern)
  stringr::str_match(string = string, pattern = pattern)

str_match reports NA, while str_match_all reports an empty string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions