I am trying to remove non Arabic words in r and i tried this code but it is removed everything
> L<-"you المجدo to yes"
> gsub("[^\\p{InArabic}.,]+","",L)
[1] ""
You need to add perl = TRUE
in order for R to compile the regex in PCRE mode.
Also I'm not sure that {InArabic}
is a supported character class - though {Arabic}
does seem to be, at least in my version of R (R version 3.4.4 (2018-03-15) -- "Someone to Lean On"):
> L<-"you المجدo to yes"
>
> gsub("[^\\p{Arabic}.,]+", "", L, perl = TRUE)
[1] "المجد"
perl = TRUE
in order for R to compile the regex in PCRE mode. Also I'm not sure that{InArabic}
is supported - though{Arabic}
does seem to be ex.gsub("[^\\p{Arabic}.,]+", "", L, perl = TRUE)