Language: R, IDE: R Studio
I'm writing a script to extract and exclude specific information from a pdf file (a.k.a a massive string). I used grep to split the string into pages I want. I'm looking to slim this down even further. My script to slim it down more is...
variablename <- grep("Additional Information:(?! )", AnyAdditionalInfoPages,
perl = TRUE, value = TRUE)
This works exactly how I want it. I'm new to R and regex, however, so I wanted to practice and I tried the following...
variablename <- grep("Additional Information:(?!\s)", AnyAdditionalInfoPages,
perl = TRUE, value = TRUE)
The result was - Error: '\s' is an unrecognized escape in character string starting ""Additional Information:(?!\s"
AND
variablename <- grep("Additional Information:(?!\\s)", AnyAdditionalInfoPages,
perl = TRUE, value = TRUE)
The result is an empty variable
> variablename
character(0)
What's going on? Why does " " work but the escape character for string \s not work?