0

I'm new to R, but used to regex in Perl and I'm trying to pull information using regular expressions from a file that I've downloaded. Here's what isn't working:

regex <- "([\\w\\.\\,]{1,10})[ ]*?([\\w\\d-]*).*?(\\d{6}).*?(\\d\\d\\d\\d\\-\\d\\d\\-\\d\\d)(.*)"
line <- "allied          8-K         927454      2020-01-21  edgar/data/0001683168-20-000194.txt"
grep(regex, line, value = TRUE, perl = TRUE)

When I run the code, it returns the entire line.

I want a list (or something like a list) that returns "allied", "8-K", "927454", "2020-01-21", and "edgar/data/0001683168-20-000194.txt"

I also tried

str_extract_all(line, regex)

with the same results. I've tested my pattern at regex101.com and it works fine there.

Cyrus
  • 84,225
  • 14
  • 89
  • 153
Eric
  • 1
  • 1
  • 1

0 Answers0