Enes I.
Enes I.

Reputation: 125

Ignore special Turkish characters when partial matching

Suppose that we have a "AMID DIMAD YUZBASIOGLU" string. What I want to do is to match possible strings such as "AMİD YÜZBAŞIOĞLU","AMID YÜZBAŞIOĞLU", "AMID DİMAD YÜZBAŞIOĞLU" with "AMID DIMAD YUZBASIOGLU" using grep function.

Upvotes: 1

Views: 41

Answers (1)

Jilber Urbina
Jilber Urbina

Reputation: 61204

We can use iconv(your_string, to='ASCII//TRANSLIT') to convert special characters to 'ASCII' and then use grep

> x <- "AMID DIMAD YUZBASIOGLU" 
> string <- c("AMİD YÜZBAŞIOĞLU","AMID YÜZBAŞIOĞLU","AMID DİMAD YÜZBAŞIOĞLU")
> y <- iconv(string, to='ASCII//TRANSLIT')
> grep(x, y)
[1] 3

Upvotes: 1

Related Questions