I'm having some problems matching a pattern with a string of text in R
.
I'm trying to get TRUE
with grepl
when the text is something like "lettersornumbersorspaces y lettersornumbersorspaces".
I'm using the following regex
:
([:alnum:]|[:blank:])+[:blank:][yY][:blank:]([:alnum:]|[:blank:])+
When using the regex
as follows to obtain the "address" it works at expected.
regex <- "([:alnum:]|[:blank:])+[:blank:][yY][:blank:]([:alnum:]|[:blank:])+"
address <- str_extract(fulltext, regex)
I see that address is the text that I need. Now, if I want to use grepl
to get a TRUE
as follows:
grepl("([:alnum:]|[:blank:])+[:blank:][yY][:blank:]([:alnum:]|[:blank:])+", address,ignore.case = TRUE)
FALSE
is returned. How is this possible? I'm using the same regex
to get TRUE
. I have tried modifications to the grepl
parameters, but non of them is related to this.
An example of text is: "26 de Marzo y Pareyra de la Luz"
Thanks!!