-1

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] ""
1
  • You likely need to add 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) Dec 30, 2018 at 22:40

1 Answer 1

2

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] "المجد"

Not the answer you're looking for? Browse other questions tagged .