[R] Searching for Enumerated Items using str_count() from the stringr package
toth.denes at kogentum.hu
Fri Sep 29 00:02:45 CEST 2017
On 09/28/2017 10:25 PM, Dan Abner wrote:
> Hi all,
> I have a large number of text strings to search for enumerated items.
> However, I am receiving this error message even though I thought that I
> properly escaped the special character closed parenthesis:
> Error in stri_count_regex(string, pattern, opts_regex = opts(pattern)) :
> Syntax error in regexp pattern. (U_REGEX_RULE_SYNTAX)
> Here is example code:
> text1<-"This is a list:
> 1) Number 1
> 2) Etc
> 3) Etc"
> text2<-"This is NOT a list:
> Blah, blah, blah
> Blah, blah, blah"
You should carefully read the docs, see ?regexp.
You really do not want to pass a multi-element vector as 'keywords' in
this case, but instead:
stri_count_regex(text3, "[0-9]+\\) ")
stri_count_regex(text3, "[[:digit:]]+\\) ")
BTW, I do not understand why to use the stringr package if it is just a
wrapper around the stringi package.
> I am looking for Count<-c(3,0)
> Any suggestions?
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Dr. Tóth Dénes ügyvezető
More information about the R-help