         var firstFlg: Bool = false
         for genre in genres {
             if !firstFlg {
-                selectGenre += "AND (title CONTAINS[c] '\(genre)' "
+                selectGenre += "AND (title CONTAINS[c] '\(genre.realmEscaped)' "
                 firstFlg = true
             }
-            selectGenre += "OR title CONTAINS[c] '\(genre)' "
+            selectGenre += "OR title CONTAINS[c] '\(genre.realmEscaped)' "
         }
         // 0は許容していないがバグ回避のためチェック
         if genres.count != 0 {

        if term != "" {
            for termWord in termArr {
                if !firstFlg {
                    selectGenre += "AND (title CONTAINS[c] '\(termWord)' OR address CONTAINS[c] '\(termWord)' OR  place CONTAINS[c] '\(termWord)' "
                    firstFlg = true
                } else {
                    selectGenre += "OR title CONTAINS[c] '\(termWord)' OR address CONTAINS[c] '\(termWord)' OR  place CONTAINS[c] '\(termWord)' "
                }
            }
            if termArr.count != 0 {

        return place
    }
}

public extension String {

    public var realmEscaped: String {
        let reps = [
            "\\" : "\\\\",
            "'"  : "\\'",
            ]
        var ret = self
        for rep in reps {
            ret = self.stringByReplacingOccurrencesOfString(rep.0, withString: rep.1)
        }
        return ret
    }
}
