Home > Mobile >  Remove all special characters from string except Turkish ones
Remove all special characters from string except Turkish ones

Time:01-17

there are tons of similar questions but i couldn't find the exact answer.

I have a text like this;

str <- "NG*-# ÜÇ12 NET GROUPنت ياترم "

I want to remove all special and non-Turkish characters and keep the others. Desired output is;

"NGÜÇ12 NET GROUP"

I really appreciate your help.

CodePudding user response:

Please try

library(stringr)
str <- "NG*-# ÜÇ12 NET GROUPنت ياترم "
str_replace_all(str, '[^[\\da-zA-Z ÜüİıÇ窺Ğğ]]', '')

CodePudding user response:

Using base gsub:

gsub("[^0-9a-zA-Z ÜüİıÇ窺Ğğ]", "", str)
# [1] "NGÜÇ12 NET GROUP  "
  • Related