I am trying to search for curly brackets in text strings in R, using the stringr package. Using the following code:
library(stringr)
textstring <- 'abc}defg}hij'
str_locate_all(textstring, 'e')
works fine, but
str_locate_all(textstring, '}')
gives the following error message:
Error in stri_locate_all_regex(string, pattern, omit_no_match = TRUE, : Syntax error in regexp pattern. (U_REGEX_RULE_SYNTAX)
I am using R version 3.2.1 and stringr version 1.0.0 in Ubuntu 14.04 LTS.
Can anyone help me, please?
{
is a special character - you have to escape it:
str_locate_all(textstring, '\\}')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With