In regex, mystery Error: assertion 'tree->num_tags == num_tags' failed in executing regexp: file 'tre-compile.c', line 634

后端 未结 2 1534
感情败类
感情败类 2020-12-19 10:05

Assume 900+ company names pasted together to form a regex pattern using the pipe separator -- \"firm.pat\".

firm.pat <- str_c(firms$firm, collapse = \"|\"         


        
相关标签:
2条回答
  • 2020-12-19 10:21

    I had the same problem with pattern consisiting of hundreds of manufacters names. As I can suggest the pattern is too long, so I split it in two or more patterns and it works well.

      ml<-length(firms$firm)
      xyz<-gsub(sprintf("(*UCP)\\b(%s)\\b", paste(head(firms$firm,n=ml/2), collapse = "|")), "", bio$comment, perl=TRUE)
      xyz<-gsub(sprintf("(*UCP)\\b(%s)\\b", paste(tail(firms$firm,n=ml/2), collapse = "|")), "", xyz, perl=TRUE)
    
    0 讨论(0)
  • 2020-12-19 10:27

    You can use mgsub in the qdap package, which is an extension to gsub that handles vectors of patterns and replacements.

    Please refer to this Answer

    0 讨论(0)
提交回复
热议问题