Hoşgeldin. Soru sormak veya cevaplamak için hemen üye ol.
0 oy
352 kez görüntülendi
ios development kategorisinde tarafından

Şu şekilde bir string var:

\\This is a \\test string

Ben bu iki slash \\ işaretini şöyle silmeye çalışıyorum ama sadece tekini siliyor. Ne yapmam lazım?

let test = \\This is a \\test string
test.replacingOccurrences(of:  test, with: "")

Sonucun şöyle olması lazım:
This is a test string.

1 cevap

0 oy
tarafından
let test: String = "\\This is a \\test string"
test.replacingOccurrences(of: "\\", with: "")
tarafından

Denedim. Ama print edince şöyle gösteriyor:

\This is a \test string
tarafından

Zannedersem bir sorun var. Xcode 11.4 (11E146) kullanıyorum. Siz de bir dener misiniz print ile.

tarafından

Ben de xCode 11.4 kullanıyorum. playgorund'da denedim yine aynı sonucu aldım.
enter image description here

tarafından

Çok ilginç. Ben bir macOS uygulaması içindeki viewcontroller de deniyorum print ie. Anlayamadım gitti, neden ikisini birden silmiyor. Çok enteresan bir durum.

...